> Paul Fenwick <pjf <at> perltraining.com.au> writes: > >>for ($foo) { >> when ($_ < 500) { ++$_ } >> when ($_ > 1000) { --$_ } >> default { say "Just right $_" } >>} > > Ahh... that's exactly what I was looking for. Thanks. > > Makes you wonder why the 'given' keyword was added, when for/when is so > close...
I'd assume 'given' provides scalar context onto its argument, 'for' obviously provides list context. But I guess the main difference is that 'for' is associated with iteration, and IMHO it feels unnatural to iterate over one item. -- Moritz Lenz http://moritz.faui2k3.org/ | http://perl-6.de/
signature.asc
Description: OpenPGP digital signature