I've been trying to write a script by using a switch statement. I think I've found two different ways to write one, but neither way seems to work. I remember it saying something about a switch module, but I don't know if I have one of those or if I have to download one.
CODE
#!/usr/bin/perl
use strict
use Switch
do{
print"say something to grandma\n";
my $saying=<>;
my $year= rand(20)+1930;
switch ($saying)
{
case (lc($saying)) {print"HUH?!, speak up sonny!";}
case (uc($saying)) {print"No, not since int($year)!";}
}
} while($saying ne BYE);
The program is supposed to take in a string and say one thing if it is all in lowercase and another thing if it is all in Upper case. I don't want anyone to correct the code, just point me in the right direction. If I do have to download some sort of module could you tell me where?
I also saw that "Perl 6 will provide a built-in switch statement " and that "In Perl 6 switch will be spelled given, and case will be pronounced when". I also tried it with these key words instead of switch and case, but it still didn't work.
This post has been edited by enigma-paradox: 23 Jun, 2008 - 01:03 PM