$VAR1 = [ '-type', 'sugar', '-unit', '6' ]; # where $sometype = 'foo'; $some_unit = 6; #### 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 }