The Switch.pm Module : switch « Statement « Perl






The Switch.pm Module

 

use Switch;

print "What is your favorite color? ";
chomp($color=<STDIN>);
switch("$color"){
   case "red"  { print "Red!\n"; }
   case "blue" { print "blues.\n"; }
   case "green" { print "green\n";}
   case "yellow" { print "yellow";}
   else          { print "$color is not in our list.\n";}
}
print "Execution continues here....\n";

   
  








Related examples in the same category

1.Switch on sub
2.Swich for data type