diff options
Diffstat (limited to 'lib/Getopt')
-rw-r--r-- | lib/Getopt/Std.pm | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/Getopt/Std.pm b/lib/Getopt/Std.pm index 18b5739e92..c2cd1234f4 100644 --- a/lib/Getopt/Std.pm +++ b/lib/Getopt/Std.pm @@ -57,7 +57,7 @@ the argument or 1 if no argument is specified. sub getopt ($;$) { local($argumentative, $hash) = @_; local($_,$first,$rest); - local $Exporter::ExportLevel; + local @EXPORT; while (@ARGV && ($_ = $ARGV[0]) =~ /^-(.)(.*)/) { ($first,$rest) = ($1,$2); @@ -93,8 +93,10 @@ sub getopt ($;$) { } } } - $Exporter::ExportLevel++; - import Getopt::Std; + unless (ref $hash) { + local $Exporter::ExportLevel = 1; + import Getopt::Std; + } } # Usage: @@ -105,7 +107,7 @@ sub getopts ($;$) { local($argumentative, $hash) = @_; local(@args,$_,$first,$rest); local($errs) = 0; - local $Exporter::ExportLevel; + local @EXPORT; @args = split( / */, $argumentative ); while(@ARGV && ($_ = $ARGV[0]) =~ /^-(.)(.*)/) { @@ -153,8 +155,10 @@ sub getopts ($;$) { } } } - $Exporter::ExportLevel++; - import Getopt::Std; + unless (ref $hash) { + local $Exporter::ExportLevel = 1; + import Getopt::Std; + } $errs == 0; } |