use Getopt::Std;
use strict;
our($opt_i); # "our" allows strict use of this variable without clobbe
+ring it
getopts('i:');
| [reply] [d/l] |
I apologize for getting off topic. Sounds like you have your problem solved with an LWP upgrade. But since we are already there...
You can read more about "our" at our variables.
If you "clobber" an "our" variable, you get a warnings, but it is still there and accessible with the full name. See demo code below. To declare a variable before use, "my" is almost always the "right answer", even with getopts.
A "my" variable is completely "private" and cannot be accessed except in the scope and package in which it is declared. An "our" variable gets put into the package's symbol table and can be accessed by a different compilation unit, if the full name is used or if it is "exported" and "imported" by another package.
#!usr/bin/perl
use warnings;
use strict;
our $x = 99;
my $x = 4;
print "lexical my version of x=$x\n";
print "package version of x=$main::x";
__END__
"my" variable $x masks earlier declaration in same scope at C:\testing
+\ourdemo.pl line 6.
lexical my version of x=4
package version of x=99
| [reply] [d/l] |