use warnings; use strict; die "Enter proper CLI arugments: ......." unless @ARGV == 2; ## check your arguments passed from CLI my ( $num1, $num2 ) = show_now(@ARGV); print $num1, "\t", $num2, $/; sub show_now { my ( $inp1, $inp2 ) = @_; print "inp1 is $inp1 inp2 is $inp2\n"; my ( $opt1, $value1, $opt2, $value2 ) = ""; if ( $inp1 =~ /rel=.+?/i ) { ## changed the regex ( $opt1, $value1 ) = split( /=/, $inp1 ); } if ( $inp2 =~ /file=.?+/i ) { ## changed the regex ( $opt2, $value2 ) = split( /=/, $inp2 ); } if ( $inp1 !~ /rel=.+?/i or $inp2 !~ /file=.+?/i ) { print "\n[Error] - Wrongly passed the parameter.\n"; print " Please use correct format as below\n"; print "\n[Example] - rel= file=(\$script_name rel=102b file= ccmsg.1)\n\n"; #exit; ## not really needed } return ( $value1, $value2 ) if wantarray(); }