switch.t revision 7c478bd95313f5f23a4c958a745db2134aa03244
#!./perl
# $RCSfile: switch.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:14 $
print "1..18\n";
sub foo1 {
$_ = shift(@_);
$a = 0;
until ($a++) {
next if $_ eq 1;
next if $_ eq 2;
next if $_ eq 3;
next if $_ eq 4;
return 20;
}
continue {
return $_;
}
}
sub foo2 {
$_ = shift(@_);
{
last if $_ == 1;
last if $_ == 2;
last if $_ == 3;
last if $_ == 4;
}
continue {
return 20;
}
return $_;
}
sub foo3 {
$_ = shift(@_);
if (/^1/) {
return 1;
}
elsif (/^2/) {
return 2;
}
elsif (/^3/) {
return 3;
}
elsif (/^4/) {
return 4;
}
else {
return 20;
}
return 40;
}