Code: #!/usr/local/bin/perl use strict; use Getopt::Long qw(:config gnu_getopt); ########################################### # Parses the commad line arguments # Example: callfunction.pl -action getInfo ########################################### sub parse_args { my %opts; GetOptions(\%opts, "action=s", ); return %opts; } my %opts = parse_args(); my $action = $opts{action}; my $output = call_function($action, %opts); =head call_function ($function_name, %params) This method invokes the appropriate subroutine based on the funcname passed =cut sub call_function { my $funcname = shift; my %opts = @_; my $package = 'main'; if ( my $func = UNIVERSAL::can($package, $funcname) ) { $func->(%opts); } else { die "no such function $package\::$funcname\n"; } } sub getInfo { my $msg = shift; return $msg; }