Pod::Parser updates (v1.091) from Brad Appleton <bradapp@enteract.com>
[p5sagit/p5-mst-13.2.git] / lib / Getopt / Std.pm
index 18b5739..390bf14 100644 (file)
@@ -42,8 +42,7 @@ the argument or 1 if no argument is specified.
 
 @ISA = qw(Exporter);
 @EXPORT = qw(getopt getopts);
-
-# $RCSfile: getopt.pl,v $$Revision: 4.1 $$Date: 92/08/07 18:23:58 $
+$VERSION = $VERSION = '1.01';
 
 # Process single-character switches with switch clustering.  Pass one argument
 # which is a string containing all switches that take an argument.  For each
@@ -57,7 +56,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 +92,10 @@ sub getopt ($;$) {
            }
        }
     }
-    $Exporter::ExportLevel++;
-    import Getopt::Std;
+    unless (ref $hash) { 
+       local $Exporter::ExportLevel = 1;
+       import Getopt::Std;
+    }
 }
 
 # Usage:
@@ -105,7 +106,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]) =~ /^-(.)(.*)/) {
@@ -143,7 +144,7 @@ sub getopts ($;$) {
            }
        }
        else {
-           print STDERR "Unknown option: $first\n";
+           warn "Unknown option: $first\n";
            ++$errs;
            if($rest ne '') {
                $ARGV[0] = "-$rest";
@@ -153,8 +154,10 @@ sub getopts ($;$) {
            }
        }
     }
-    $Exporter::ExportLevel++;
-    import Getopt::Std;
+    unless (ref $hash) { 
+       local $Exporter::ExportLevel = 1;
+       import Getopt::Std;
+    }
     $errs == 0;
 }