summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-12-21 13:04:42 -0800
committerFather Chrysostomos <sprout@cpan.org>2011-12-22 13:31:22 -0800
commitb861b87ffee6ad459fd7a2e4ee74d162f6e7ca70 (patch)
tree7fb1d783d1902e8ab40e496be6b47d2742b20a0b
parent10e8e32b3dba62bbc9452bff12981666bbf0fe4e (diff)
downloadperl-b861b87ffee6ad459fd7a2e4ee74d162f6e7ca70.tar.gz
Deparse "a::]"->[0], etc., correctly
The package name should not be omitted when the name begins with punc- tuation unless the variable is in the main package. "]"->[0] is force into the main package. "a::]"->[0] is not.
-rw-r--r--dist/B-Deparse/Deparse.pm5
-rw-r--r--dist/B-Deparse/t/deparse.t6
2 files changed, 9 insertions, 2 deletions
diff --git a/dist/B-Deparse/Deparse.pm b/dist/B-Deparse/Deparse.pm
index 927afd5bd7..b33a407273 100644
--- a/dist/B-Deparse/Deparse.pm
+++ b/dist/B-Deparse/Deparse.pm
@@ -1259,10 +1259,11 @@ Carp::confess() unless ref($gv) eq "B::GV";
if ($stash eq 'main' && $name =~ /^::/) {
$stash = '::';
}
- elsif (($stash eq 'main' && $globalnames{$name})
+ elsif (($stash eq 'main'
+ && ($globalnames{$name} || $name =~ /^[^A-Za-z_:]/))
or ($stash eq $self->{'curstash'} && !$globalnames{$name}
&& ($stash eq 'main' || $name !~ /::/))
- or $name =~ /^[^A-Za-z_:]/)
+ )
{
$stash = "";
} else {
diff --git a/dist/B-Deparse/t/deparse.t b/dist/B-Deparse/t/deparse.t
index 780d8b3093..3479706cbf 100644
--- a/dist/B-Deparse/t/deparse.t
+++ b/dist/B-Deparse/t/deparse.t
@@ -908,27 +908,33 @@ no strict 'vars';
() = '####'->[0];
() = '^A'->[0];
() = "\ca"->[0];
+() = 'a::]b'->[0];
() = 'open'->[$_]; #aelem
() = '####'->[$_];
() = '^A'->[$_];
() = "\ca"->[$_];
+() = 'a::]b'->[$_];
() = 'open'->{0}; #helem
() = '####'->{0};
() = '^A'->{0};
() = "\ca"->{0};
+() = 'a::]b'->{0};
>>>>
() = $open[0];
() = '####'->[0];
() = '^A'->[0];
() = $^A[0];
+() = 'a::]b'->[0];
() = $open[$_];
() = '####'->[$_];
() = '^A'->[$_];
() = $^A[$_];
+() = 'a::]b'->[$_];
() = $open{'0'};
() = '####'->{'0'};
() = '^A'->{'0'};
() = $^A{'0'};
+() = 'a::]b'->{'0'};
####
# [perl #74740] -(f()) vs -f()
$_ = -(f());