summaryrefslogtreecommitdiff
path: root/lib/Getopt
diff options
context:
space:
mode:
authorTom Phoenix <rootbeer@teleport.com>1998-04-29 15:48:16 -0700
committerMalcolm Beattie <mbeattie@sable.ox.ac.uk>1998-05-14 15:58:01 +0000
commit535b5725d48083aeb233abbcdfef2fd3274b2619 (patch)
treea28dda24803e56c60926ae11f1201e063ff236c6 /lib/Getopt
parent52cebf5efc9883c776f89be24e988c47ceba2a42 (diff)
downloadperl-535b5725d48083aeb233abbcdfef2fd3274b2619.tar.gz
Using Getopts::* with strict vars
p4raw-id: //depot/perl@964
Diffstat (limited to 'lib/Getopt')
-rw-r--r--lib/Getopt/Long.pm6
-rw-r--r--lib/Getopt/Std.pm6
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/Getopt/Long.pm b/lib/Getopt/Long.pm
index 5b5b495b57..fe7e12f09b 100644
--- a/lib/Getopt/Long.pm
+++ b/lib/Getopt/Long.pm
@@ -955,6 +955,12 @@ identifier is $opt_ .
The linkage specifier can be a reference to a scalar, a reference to
an array, a reference to a hash or a reference to a subroutine.
+Note that, if your code is running under the recommended C<use strict
+'vars'> pragma, it may be helpful to declare these package variables
+via C<use vars> perhaps something like this:
+
+ use vars qw/ $opt_size @opt_sizes $opt_bar /;
+
If a REF SCALAR is supplied, the new value is stored in the referenced
variable. If the option occurs more than once, the previous value is
overwritten.
diff --git a/lib/Getopt/Std.pm b/lib/Getopt/Std.pm
index 27882935f9..18b5739e92 100644
--- a/lib/Getopt/Std.pm
+++ b/lib/Getopt/Std.pm
@@ -27,6 +27,12 @@ switch name) to the value of the argument, or 1 if no argument. Switches
which take an argument don't care whether there is a space between the
switch and the argument.
+Note that, if your code is running under the recommended C<use strict
+'vars'> pragma, it may be helpful to declare these package variables
+via C<use vars> perhaps something like this:
+
+ use vars qw/ $opt_foo $opt_bar /;
+
For those of you who don't like additional variables being created, getopt()
and getopts() will also accept a hash reference as an optional second argument.
Hash keys will be x (where x is the switch name) with key values the value of