I don’t know the exact requirements, but this is a workaround that you can use without significant changes to your code.
use Getopt::Long;
my %opts;
GetOptions (\%opts, 'abc', 'def', 'ghi');
&print_abc if($opts{abc});
&print_def if($opts{def});
&print_ghi if($opts{ghi});
sub print_abc(){print "inside print_abc\n"}
sub print_def(){print "inside print_def\n"}
sub print_ghi(){print "inside print_ghi\n"}
and then call the program as follows:
perl test.pl -abc -def
Please note that you may omit unwanted parameters.
source
share