in reply to use strict and use Getopts
You're running into scoping issues. The easiest thing I've found is to pass a hashref as the second argument. The args get stuck in there. For instance:
#!/usr/bin/perl use strict; use Getopt::Std; { my %opts = (); getopts( 'w:h:', \%opts ); print "w: $opts{w}; h: $opts{h}\n"; }
Running like:
$ perl opts.pl -w wassup -h hey
Produces:
w: wassup; h: hey
Chris
M-x auto-bs-mode
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: use strict and use Getopts
by rbc (Curate) on Jan 11, 2002 at 02:45 UTC |