From: Marcel GrĂ¼nauer Date: Tue, 22 Jun 2004 16:43:50 +0000 (+0000) Subject: Proposed patch + test case. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e5c3f8982a1650ad4c25a05c41a9038ce21a512c;p=p5sagit%2Fp5-mst-13.2.git Proposed patch + test case. Subject: [perl #30409] charnames.pm clobbers default variable From: Marcel "GrĂ¼nauer" (via RT) Message-ID: p4raw-id: //depot/perl@22972 --- diff --git a/lib/charnames.pm b/lib/charnames.pm index 4f7fdeb..f0a4446 100644 --- a/lib/charnames.pm +++ b/lib/charnames.pm @@ -190,8 +190,8 @@ sub import ## fill %h keys with our @_ args. ## my ($promote, %h, @args) = (0); - while (@_ and $_ = shift) { - if ($_ eq ":alias") { + while (my $arg = shift) { + if ($arg eq ":alias") { @_ or croak ":alias needs an argument in charnames"; my $alias = shift; @@ -210,11 +210,11 @@ sub import alias_file ($alias); next; } - if (m/^:/ and ! ($_ eq ":full" || $_ eq ":short")) { - warn "unsupported special '$_' in charnames"; + if (substr($arg, 0, 1) eq ':' and ! ($arg eq ":full" || $arg eq ":short")) { + warn "unsupported special '$arg' in charnames"; next; } - push @args, $_; + push @args, $arg; } @args == 0 && $promote and @args = (":full"); @h{@args} = (1) x @args; diff --git a/lib/charnames.t b/lib/charnames.t index 3502b74..49917c5 100644 --- a/lib/charnames.t +++ b/lib/charnames.t @@ -15,7 +15,7 @@ require File::Spec; $| = 1; -print "1..73\n"; +print "1..74\n"; use charnames ':full'; @@ -328,6 +328,12 @@ for (@prgs) { 1 while unlink $alifile; } +# [perl #30409] charnames.pm clobbers default variable +$_ = 'foobar'; +eval "use charnames ':full';"; +print "not " unless $_ eq 'foobar'; +print "ok 74\n"; + __END__ # unsupported pragma use charnames ":scoobydoo";