Thursday, February 10, 2011

PERL : Examples using given and when statements

use feature ":5.10";
unless ($#ARGV == 0)
{
say "$0 requires 1 integer parameter in order to work";
exit 0;
}
print "\nYou have entered $ARGV[0]";
given($_)
{
when ($_ < 10)
{
say "\nNumber $input is less then 10";
}
when($_ > 10)
{
say "\nNumber $input is greater then 10";
}
}

No comments:

Post a Comment