in reply to Re^3: why each/keys/values can't work on slice? (updated)
in thread why each/keys/values can't work on slice?
I don't understand why every array has to have only one iterator, please enlighten me. and guess each/keys doesn't work on slice would be relative to this reason?use feature qw/say/; my @bb = 1..10; while(my ($ind, $val) = each @bb){ say "ind is $ind"; if($ind >5){ while(my ($inner_ind, $inner_val) = each @bb){ say "inner ind is $inner_ind, inner val is $inner_v +al" } } } # will endless loop since while share one iterator while(my ($ind, $val) = each @bb){ say "ind is $ind"; } # this will quit loop successfully.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: why each/keys/values can't work on slice? (updated)
by LanX (Saint) on Jan 11, 2023 at 05:45 UTC | |
|
Re^5: why each/keys/values can't work on slice? (updated)
by ikegami (Patriarch) on Jan 11, 2023 at 19:07 UTC |