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:
Error when using Getopts and Strict

 



popeye
Novice

Nov 25, 2013, 4:39 AM

Post #1 of 2 (1030 views)
Error when using Getopts and Strict Can't Post


Code
#!/usr/bin/perl 
use strict;
use Getopt::Std;

# Process the command line options
die "Usage: $0 -r <router> -u <username> -p <password> -e <enable password>\n" if (@ARGV < 6);

exit if (!getopts('r:u:p:e:'));

my $unam=$opt_u;
my $psswd=$opt_p;
my $epsswd=$opt_e;
my $dev=$opt_r;


print "$unam $psswd $epsswd $dev "



Quote
/home/popeye> topt -r 10.10.10.10 -u popeye -p thesailorman
Global symbol "$opt_u" requires explicit package name at topt line 10.
Global symbol "$opt_p" requires explicit package name at topt line 11.
Global symbol "$opt_e" requires explicit package name at topt line 12.
Global symbol "$opt_r" requires explicit package name at topt line 13.
Execution of topt aborted due to compilation errors.


How do I get past this error if using Getopts and strict ?

Thanks much in advance.


popeye
Novice

Nov 25, 2013, 6:14 AM

Post #2 of 2 (1029 views)
Re: [popeye] Error when using Getopts and Strict [In reply to] Can't Post

 
Got it ... just employ use vars.

 
 


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

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