perl5.01中引入的given_when(类似于C语言的switch分支语句)
#!/usr/bin/perl -w
use 5.010;
my $dog='Spot';
given ($dog) {
when (/o/) { say 'The name has an "o"'; continue }
when (/t/) { say 'The name has an "t"'; continue }
when (/d/) { say 'The name has an "d"'; continue }
}

浙公网安备 33010602011771号