randian has asked for the wisdom of the Perl Monks concerning the following question:
Trying out the arrayref functionality introduced in 5.14. The first loop executes the expected 3 times, printing the expected values. The second loops infinitely, always giving 0 for $i and 'a' for $v. Hashrefs display the same behavior.#!/usr/bin/env perl #-*-Perl-*- use v5.16; my @a = qw<a b c>; my $b = [@a]; while (my ($i, $v) = each $b) { say "$i: $v"; } while (my ($i, $v) = each [@a]) { say "$i: $v"; }
my $b = {map { $_ => $_ } qw<a b c>}; while (my ($i, $v) = each $b) { say "$i: $v"; } while (my ($i, $v) = each {map { $_ => $_ } qw<a b c>}) { say "$i: $v"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: perl v5.16 bug?
by dave_the_m (Monsignor) on Mar 15, 2013 at 23:28 UTC | |
by randian (Acolyte) on Mar 15, 2013 at 23:44 UTC | |
|
Re: perl v5.16 bug?
by tobyink (Canon) on Mar 15, 2013 at 23:38 UTC | |
|
Re: perl v5.16 bug? (:sure:)
by Anonymous Monk on Mar 16, 2013 at 07:05 UTC | |
by ikegami (Patriarch) on Mar 16, 2013 at 19:06 UTC |