Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the PPI CPAN distribution.

Report information
The Basics
Id: 21571
Status: resolved
Priority: 0/
Queue: PPI

People
Owner: Nobody in particular
Requestors: pguzis [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.116
Fixed in: (no value)



Subject: PPI::Token::Symbol::symbol does not properly handle variables with adjacent braces
The symbol method in PPI::Token::Symbol incorrectly returns "$" for arrays and hashes with adjacent braces. For example, symbol called on $foo{bar} returns "$" not the intended "%foo". The four-argument substr commands within symbol are returning the original leading character of each variable name. I have confirmed this behavior on Perl versions 5.6.0 and 5.6.1 (Solaris 8), and ActivePerl 5.6.1 and 5.8.8 (Windows XP). Please see the attached patch file for a fix.
Subject: symbol_patch.txt
--- Symbol.pm Sat Sep 2 00:03:24 2006 +++ Symbol.pm Tue Sep 19 17:08:29 2006 @@ -98,12 +98,19 @@ my $braces = $after->braces; return $symbol unless defined $braces; if ( $type eq '$' ) { - return substr( $symbol, 0, 1, '@' ) if $braces eq '[]'; - return substr( $symbol, 0, 1, '%' ) if $braces eq '{}'; - + if ( $braces eq '[]' ) { + substr( $symbol, 0, 1, '@' ); + return $symbol; + } + if ( $braces eq '{}' ) { + substr( $symbol, 0, 1, '%' ); + return $symbol; + } } elsif ( $type eq '@' ) { - return substr( $symbol, 0, 1, '%' ) if $braces eq '{}'; - + if ( $braces eq '{}' ) { + substr( $symbol, 0, 1, '%' ); + return $symbol; + } } $symbol;
From: CLOTHO [...] cpan.org
I've committed to SVN a test and a simpler patch for this bug as SVN revision 1047.
Marking as resolved.