Divakar has asked for the wisdom of the Perl Monks concerning the following question:
Hi Folks,
When i execute my script as below
it is coming out of the script after printing below statement. it is checking the wrong condition.. i dont know why. can someone please help?check_build_test_time_run_test.pl rel=102b file=ccmsg.2
[Error] - Wrongly passed the parameter. Please use correct format as below [Example] - <scriptname> rel=<release> file=<file_name>(./check_build_ +test_time_run_test.pl rel=102b file=ccmsg.1)
I am checking the input parameters passing to the script and validating the parameters before return. below is my subroutine.
Thank you..if ($no_of_arg == 2) { my($inp1,$inp2)=@ARGV; chomp($inp1,$inp2); print "inp1 is $inp1 inp2 is $inp2\n"; print "inp1 is $inp1 inp2 is $inp2\n"; my ($opt1,$value1,$opt2,$value2)=""; if ($inp1 =~ /^rel=\w+$/i) { ($opt1,$value1)=split(/=/,$inp1); } if ($inp2 =~ /^file=\w+$/i) { ($opt2,$value2)=split(/=/,$inp2); } if ($inp1 !~ /^rel=\w+$/i or $inp2 !~ /^file=\w+$/i) { print "\n[Error] - Wrongly passed the paramete +r.\n"; print " Please use correct format as +below\n"; print "\n[Example] - <scriptname> rel=<release +> file=<file_name>($script_name rel=102b file= ccmsg.1)\n\n"; exit; } return($value1,$value2); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Checking Wrong Condition
by moritz (Cardinal) on Apr 25, 2012 at 08:22 UTC | |
by Divakar (Sexton) on Apr 25, 2012 at 12:15 UTC | |
|
Re: Checking Wrong Condition
by BrowserUk (Patriarch) on Apr 25, 2012 at 08:29 UTC | |
by Divakar (Sexton) on Apr 25, 2012 at 12:19 UTC | |
|
Re: Checking Wrong Condition
by 2teez (Vicar) on Apr 25, 2012 at 09:15 UTC | |
by Divakar (Sexton) on Apr 25, 2012 at 17:30 UTC | |
by 2teez (Vicar) on Apr 26, 2012 at 00:23 UTC |