No such thing as a small change | |
PerlMonks |
Re: why each/keys/values can't work on slice? (updated)by LanX (Saint) |
on Jan 10, 2023 at 14:58 UTC ( [id://11149494]=note: print w/replies, xml ) | Need Help?? |
ehm keys @bb[1..5] should return 1..5 (if defined) not 0..4 like demonstrated by you. This ambiguity in interpretation should already explain why it's not implemented.
updatethe technical answer is that each/keys/values operate on variables like hashes (or arrays in newer Perls) and manipulate an internal iterator counter. But a slice returns a LIST and not a variable, otherwise your intended feature would require implementing separate counters for each slice. Anyway you can always create a temporary variable on the fly, if you really need to apply each/keys/values ...
Cheers Rolf
In Section
Seekers of Perl Wisdom
|
|