#!/usr/bin/perl
# ./test3.perl
if ($#ARGV < 0) {
print "usage ./test1.perl\n";
exit 0;
}
my %ages;
my $name = $ARGV[0];
%ages = (
humble => 27,
honey => 21,
joseph => 55,
philo => 50,
none => 100
);
if (not exists $ages{$name}) {
die "invalid name \"$name\"\n";
}
die "invalid name \"$name\"\n" if ($name eq "none");
$name ne "none" or die "invalid name \"$name\"\n";
print "age of $name is $ages{$name}.\n";
if ( 3 < 5 ) {
print "3 is less than 5\n";
} else {
print "5 is less than 3\n";
}
if ( "three" lt "five") {
print "\"three\" is less then \"five\"\n";
} else {
print "\"five\" is less then \"three\"\n";
}
output: ./test3.perl humble
age of humble is 27.
3 is less than 5
"five" is less then "three"
No comments:
Post a Comment