
waldauf
Novice
Aug 23, 2012, 5:58 AM
Post #5 of 7
(860 views)
|
|
Re: [rovf] Use subroutine instead die message
[In reply to]
|
Can't Post
|
|
I was talking about Perl of course but I bad wrote Python (now it is fixed) :]. I found out solution which was very simply so I wanted to remove my topic but I removed only first post. I'll fix it. I couldn't run subroutine instead of "die message" because I removed word "die". Now it is working fine. My previous line:
GetOptions ('channel=s' => \$channel, 'state=s' => \$state) or BadInputParam_s(@ARGV); And the solution:
GetOptions ('channel=s' => \$channel, 'state=s' => \$state) or die BadInputParam_s(@ARGV); Now I have problem with handover variable/scalar to subroutine. Permit parameters are -s|--state and -c|--channel.
sub BadInputParam_s { print <<EOF; Input parameter: @_ is not allowed. For more information use help screen. EOF exit 1; } #GetOptions ('channel=s' => \$channel, 'state=s' => \$state, 'help' => \$help) or die "Uncorrect usege!\n"; GetOptions ('channel=s' => \$channel, 'state=s' => \$state, 'help' => \$help) or die BadInputParam_s(@ARGV); Output:
~ $ ./remote_channel_ctrl.pl -a Input parameter: is not allowed. For more information use help screen.
(This post was edited by waldauf on Aug 23, 2012, 6:11 AM)
|