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: 14440
Status: resolved
Priority: 0/
Queue: PPI

People
Owner: Nobody in particular
Requestors: perl [...] renee-baecker.de
Cc:
AdminCc:

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



Subject: PPI doesn't find 'all' variables
Download (untitled) / with headers
text/plain 856b
Show quoted text
> PPI doesn't find 'all' variables: > > My script: > > #!/usr/bin/perl > > use strict; > use warnings; > use PPI; > use Data::Dumper; > > my $doc = PPI::Document->new('./UPC/Window.pm'); > > my @vars = map{$_->variables}@{$doc->find('PPI::Statement::Variable')}; > print Dumper(\@vars); > > The parsed Module: > > package UPC::Window; > > use strict; > use warnings; > use Tk; > use Tk::Zinc; > > use base 'Tk::MainWindow'; > > our $VERSION = '0.01'; > our %CONFIG = (); > > sub new{ > my ($class) = @_; > my $self = {}; > bless $self,$class; > > return $self; > }# new > > sub build_display{ > }# build_display > > sub run{ > }# run > > $class is missed. In the anonymous array returned by $doc->find() you > can find the variable, but it gets lost when calling ->variables.
My system: PPI 1.003 Perl5.8.7 (ActivePerl) WinXP Home
Download (untitled) / with headers
text/plain 1.7k
Sorry, haven't seen your ticket before... The following code works... It's a patch for PPI::Statement::Variable sub variables { my $self = shift; # Get the children we care about my @schild = grep { $_->significant } $self->children; shift @schild if isa($schild[0], 'PPI::Token::Label'); # If the second child is a symbol, return its name if ( isa($schild[1], 'PPI::Token::Symbol') ) { return $schild[1]->canonical; } # If it's a list, return as a list if ( ref($schild[1]) eq 'PPI::Structure::List' ) { my @array = grep{$_->significant}$schild[1]->children; my $symbols = $array[0]->find('PPI::Token::Symbol') or return (); return map { $_->canonical } @$symbols; } # erm... this is unexpected (); } Regards, Renee Baecker [RENEEB - Sat Sep 3 13:09:31 2005]: Show quoted text
> > PPI doesn't find 'all' variables: > > > > My script: > > > > #!/usr/bin/perl > > > > use strict; > > use warnings; > > use PPI; > > use Data::Dumper; > > > > my $doc = PPI::Document->new('./UPC/Window.pm'); > > > > my @vars = map{$_->variables}@{$doc-
> >find('PPI::Statement::Variable')};
> > print Dumper(\@vars); > > > > The parsed Module: > > > > package UPC::Window; > > > > use strict; > > use warnings; > > use Tk; > > use Tk::Zinc; > > > > use base 'Tk::MainWindow'; > > > > our $VERSION = '0.01'; > > our %CONFIG = (); > > > > sub new{ > > my ($class) = @_; > > my $self = {}; > > bless $self,$class; > > > > return $self; > > }# new > > > > sub build_display{ > > }# build_display > > > > sub run{ > > }# run > > > > $class is missed. In the anonymous array returned by $doc->find()
> you
> > can find the variable, but it gets lost when calling ->variables.
> > > My system: > PPI 1.003 > Perl5.8.7 (ActivePerl) > WinXP Home
Download (untitled) / with headers
text/plain 202b
[RENEEB - Sat Sep 3 16:31:51 2005]: Show quoted text
> > # If it's a list, return as a list > if ( ref($schild[1]) eq 'PPI::Structure::List' ) {
This should be if(isa($schild[1], 'PPI::Structure::List')){


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.