Created
December 20, 2017 19:23
-
-
Save Grinnz/12deb2e4568415e33bd58ea3a27190c1 to your computer and use it in GitHub Desktop.
perlbugs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The 'each' function documentation is missing some information. | |
1. When called in scalar context in a while loop, the condition is wrapped | |
implicitly in a 'defined' check, much like with 'readline'. | |
e.g. `while (my $key = each %hash) { ... }` becomes | |
`while (defined(my $key = each %hash)) { ... }`, and | |
`while (each %hash) { ... }` becomes `while (defined($_ = each %hash)) { ... }` | |
(on 5.18+) | |
2. The iterator is not only shared and reset by calling 'keys' or 'values', but | |
also by other calls to 'each' on the same hash or array, and by accessing the | |
hash in list context (such as for assignment to another structure, or passing | |
to a function) - this last one only applies to hashes, not arrays. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When the warning "Scalar value @arrayname[0] better written as $arrayname[0]" | |
is triggered (any time an array slice is used with only one element), this results | |
in an error if the array's name starts with 'inf'. Code to reproduce: | |
use warnings; | |
my @infasdf; | |
my @x = @infasdf[0]; | |
1 | |
Error from above code (since 5.22): Cannot printf Inf with 'c' at (IRC) line 3. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment