rbc has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use strict; use Getopt::Std; my $width = 500; my $height = 500; getopts( 'w:h:' ); if( $opt_w ) { $width = $opt_w ; } if( $opt_h ) { $height = $opt_h ; } print "$height:$width\n";
Global symbol "$opt_w" requires explicit package name at ./adjust.pl l +ine 14.
#!/usr/bin/perl -w use strict; use Getopt::Std; my $width = 500; my $height = 500; my $opt_w; my $opt_h; getopts( 'w:h:' ); if( $opt_w ) { $width = $opt_w ; } if( $opt_h ) { $height = $opt_h ; } print "$width:$height\n";
$ ./my.pl -w 1000 -h 9
500:500
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: use strict and use Getopts
by runrig (Abbot) on Jan 10, 2002 at 02:27 UTC | |
|
Re: use strict and use Getopts
by lestrrat (Deacon) on Jan 10, 2002 at 02:29 UTC | |
|
Re: use strict and use Getopts
by Rich36 (Chaplain) on Jan 10, 2002 at 02:28 UTC | |
|
Re: use strict and use Getopts
by lachoy (Parson) on Jan 10, 2002 at 02:30 UTC | |
by rbc (Curate) on Jan 11, 2002 at 02:45 UTC |