develooper Front page | perl.perl5.porters | Postings from December 2017

[perl #132644] The 'each' function documentation is missing someinformation.

Thread Previous | Thread Next
karl williamson
December 22, 2017 17:40
[perl #132644] The 'each' function documentation is missing someinformation.
Message ID:
# New Ticket Created by  karl williamson 
# Please include the string:  [perl #132644]
# in the subject line of all future correspondence about this issue. 
# <URL: >

I am posting this for Dan Book, who is having trouble getting email to 
perlbug through.

The build options and version of perl is immaterial here.

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 
to a function) - this last one only applies to hashes, not arrays.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About