CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: [Laurent_R] Use subroutine instead die message: Edit Log



waldauf
Novice

Aug 23, 2012, 2:54 AM


Views: 1306
Re: [Laurent_R] Use subroutine instead die message

Hello coll's,

I'm sorry I removed the original post of this topic so I created it here. I have problem with calling subroutine instead of "die message". I replaced "die message" by subroutine but this solution didn't work.


Perl code for reading input argument:

Code
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) or BadInputParam_s(@ARGV);
~


Output:

Code
$ ./remote_channel_ctrl.pl 
$



Perl code for reading input argument. Somewhere I read I have to call subroutine like scalar variable:


Code
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) or $BadInputParam_s(@ARGV);
~


Output

Code
$ ./remote_channel_ctrl.pl 
Variable "$help_s" is not imported at ./remote_channel_ctrl.pl line 104.
(Did you mean &help_s instead?)
Global symbol "$help_s" requires explicit package name at ./remote_channel_ctrl.pl line 104.
syntax error at ./remote_channel_ctrl.pl line 107, near "print"
Execution of ./remote_channel_ctrl.pl aborted due to compilation errors.



(This post was edited by waldauf on Aug 23, 2012, 6:10 AM)


Edit Log:
Post edited by waldauf (Novice) on Aug 23, 2012, 5:58 AM
Post edited by waldauf (Novice) on Aug 23, 2012, 6:10 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives