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

Owner: Nobody in particular
Requestors: nospam-abuse [...]

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

Subject: PPI::Statement::Compound->type() for "for (@list)"
Download (untitled) / with headers
text/plain 988b
The doc for "PPI::Statement::Compound" says: type The "type" method returns the fundamental type of the com­ pound statement. [snip] Returns the simple string ’if’, ’for’ or ’while’, or "undef" if the type cannot be determined. However, the following perl script #!/usr/bin/perl -w use Test::More tests => 2; use strict; use PPI; my $code = 'for (@list) { $i++; }'; my $doc = PPI::Document->new(\$code); my $loop = $doc->{children}->[0]; is ($loop->type(), 'for', 'for my $i'); $code = 'for my $i (@list) { $i++; }'; $doc = PPI::Document->new(\$code); $loop = $doc->{children}->[0]; is ($loop->type(), 'for', 'for my $i'); prints: 1..2 ok 1 - for my $i not ok 2 - for my $i # Failed test 'for my $i' # in at line 17. # got: 'foreach' # expected: 'for' # Looks like you failed 1 test of 2. e.g. type() returns 'foreach', and not 'for'. Who is right, the doc or the code? Best wishes, Tels
Documentation previously clarified to confirm the correct behaviour

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

Please report any issues with to