From b861b87ffee6ad459fd7a2e4ee74d162f6e7ca70 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Wed, 21 Dec 2011 13:04:42 -0800 Subject: [PATCH] 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. --- dist/B-Deparse/Deparse.pm | 5 +++-- dist/B-Deparse/t/deparse.t | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/dist/B-Deparse/Deparse.pm b/dist/B-Deparse/Deparse.pm index 927afd5..b33a407 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 780d8b3..3479706 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()); -- 2.7.4