I use Getop::Long to get the argument.
I've looked at @ARGV, it gives:
$VAR1 = [ '-type', 'sugar', '-unit', '6' ];
# where
$sometype = 'foo';
$some_unit = 6;
So as you can see EMAIL option and its value is totally unrecognize here.
My overall construct under 'mycode.pl' looks like this:
use strict;
use Data::Dumper;
use Getopt::Long;
print Dumper \@ARGV ;
my $type = 'bar';
my $no_unit = 1;
my $help = 0;
my $tg_email = '';
if ( @ARGV == 0 ) {
&usage();
exit(1);
}
my $res = GetOptions ( "type=s"=>\$type,
"unit=i"=>\$no_unit,
"email=s"=>\$tg_email,
"help"=>\$help,);
if ($res) {
print "$tg_email\n" # show nothing here.
# and do some other thing
}
|