use strict;
use warnings;
use Getopt::Long;
## setup my defaults
my $name ;
my $age ;
my $help = 0;
GetOptions(
'n|name=s' => \$name,
'a|age=i' => \$age,
'help!' => \$help,
) or die "Incorrect usage!\n";
if( $help ) {
print "perl script.pl -n blog -a 2\n";
} else {
print "My name is $name.\n";
print "I am $age years old.\n";
}
-----------------------------------------------------------------------------------------------------------
:~> perl script.pl -n andre -a 22
My name is andre.
I am 22 years old.
0 comentários:
Post a Comment