| 1 |
## name Basic forward for/foreach |
| 2 |
## failures 2 |
| 3 |
## cut |
| 4 |
|
| 5 |
for (%hash) { |
| 6 |
foreach (%hash) { |
| 7 |
|
| 8 |
## name forward for/foreach with variable |
| 9 |
## failures 2 |
| 10 |
## cut |
| 11 |
|
| 12 |
for $foo (%hash) { |
| 13 |
foreach $foo (%hash) { |
| 14 |
|
| 15 |
## name forward for/foreach with lexical variable |
| 16 |
## failures 2 |
| 17 |
## cut |
| 18 |
|
| 19 |
for my $foo (%hash) { |
| 20 |
foreach my $bar (%hash) { |
| 21 |
|
| 22 |
## name postfix variations |
| 23 |
## failures 4 |
| 24 |
## cut |
| 25 |
|
| 26 |
print for %hash; |
| 27 |
print for %{$hash}; |
| 28 |
print for %{ something() }; |
| 29 |
print foreach %hash; |
| 30 |
|
| 31 |
## name reference variation |
| 32 |
## failures 8 |
| 33 |
## cut |
| 34 |
|
| 35 |
for my $foo (%{$hash}) { |
| 36 |
foreach my $bar (%$hash) { |
| 37 |
for $foo (%{$hash}) { |
| 38 |
foreach $foo (%$hash) { |
| 39 |
for (%{$hash}) { |
| 40 |
foreach (%$hash) { |
| 41 |
print for %{$hash}; |
| 42 |
print foreach %$hash; |
| 43 |
|
| 44 |
## name Correct patterns |
| 45 |
## failures 0 |
| 46 |
## cut |
| 47 |
|
| 48 |
for my $foo (keys %hash) { |
| 49 |
for my $foo (values %hash) { |
| 50 |
foreach my $bar (keys %hash) { |
| 51 |
for $foo (values %hash) { |
| 52 |
foreach $foo (keys %hash) { |
| 53 |
for (values %hash) { |
| 54 |
foreach (keys %hash) { |
| 55 |
print for values %hash; |
| 56 |
print foreach keys %hash; |
| 57 |
print for ( values %hash ); |
| 58 |
print foreach (keys %hash); |
| 59 |
print foreach (keys %{$hash}); |
| 60 |
print foreach (keys %{ some_big_thing() }); |
| 61 |
for my $k (%foo ? sort keys %foo : sort keys %bar) { |
| 62 |
for my $k (%{$foo} ? sort keys %{$foo} : sort keys %{$bar}) { |
| 63 |
for my $k (%{ func() } ? sort keys %{ func() } : sort keys %{ func() }) { |
| 64 |
|
| 65 |
## name Using "for"/"foreach" as hash key |
| 66 |
## failures 0 |
| 67 |
## cut |
| 68 |
|
| 69 |
$hash{for} |
| 70 |
$hash->{for} |
| 71 |
$hash->{ for } |
| 72 |
|
| 73 |
$hash{foreach} |
| 74 |
$hash->{foreach} |
| 75 |
$hash->{ foreach } |
| 76 |
|
| 77 |
# These came from Ahmed Abdrabo and Andy Lester |
| 78 |
## name thing() for @array statement |
| 79 |
## failures 0 |
| 80 |
## cut |
| 81 |
|
| 82 |
print for @INC |
| 83 |
say for @INC |
| 84 |
END { $dbh->do("DROP TABLE $_") foreach @table } |
| 85 |
{ print foreach @y } |
| 86 |
{ print foreach 1..2 } |
| 87 |
{ print foreach @y; } |
| 88 |
{ print } |
| 89 |
print foreach @y; |
| 90 |
|
| 91 |
## name thing() for %hash statement |
| 92 |
## failures 7 |
| 93 |
## cut |
| 94 |
|
| 95 |
print for %INC |
| 96 |
say for %INC |
| 97 |
END { $dbh->do("DROP TABLE $_") foreach %tables } |
| 98 |
{ print foreach %y } |
| 99 |
{ print foreach %{@y} } |
| 100 |
{ print foreach %y; } |
| 101 |
print foreach %y; |
| 102 |
|
| 103 |
## name Variable attributes |
| 104 |
## failures 1 |
| 105 |
## cut |
| 106 |
|
| 107 |
# this is fine |
| 108 |
for my Dog $foo (@bar) { } |
| 109 |
for my Foo::Bar $foo (@bar) { } |
| 110 |
|
| 111 |
# fails |
| 112 |
for my Foo::Bar $foo (%bar) { } |
| 113 |
|
| 114 |
## name Reference Aliasing |
| 115 |
## failures 0 |
| 116 |
## cut |
| 117 |
foreach \my %hash (@array_of_hash_references) {} |
| 118 |
|
| 119 |
## name Empty postfix loop |
| 120 |
## failures 0 |
| 121 |
## cut |
| 122 |
for Class->method($foo); |
| 123 |
|
| 124 |
## name syntax error |
| 125 |
## failures 0 |
| 126 |
## cut |
| 127 |
for my $foo @list { |