Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CASE in Perl 4 ?

Status
Not open for further replies.

browserice

Technical User
Aug 20, 2006
21
US
Is there a CASE command in Perl-4 ?
If so, what is its synthax ?
 
have a look on google for "switch.pm", it's really worth your while to upgrade to Perl 5 BTW

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
I am not talking about Perl-5 nor can I upgrade to it. I am stuck with Perl-4.
 
Try:

Code:
print "enter a color <red|green|blue> ";
my $color = <STDIN>;
chomp $color;

for ($color) {
   /red/ and do {
      print "You chose red!\n";
      last;
   };

   /blue/ and do {
      print "You chose blue!\n";
      last;
   };

   /green/ and do {
      print "You chose green!\n";
      last;
   };

   print "You weren't following directions! $color wasn't "
      . "a valid color choice!\n";
}

Its syntax looks a little different than CASE does, but it works similarly.

-------------
Kirsle.net | Kirsle's Programs and Projects
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top