in reply to Re^7: "when" and replacements
in thread "when" and replacements
No it's always an implied "next", for one-time-loops "next" and "last" just mean the same thing.
BTW: perlsyn already has such a complicated rule:
Every "when" block is implicitly ended with a "break".and
Instead of using "given()", you can use a "foreach()" loop. ... On exit from the "when" block, there is an implicit "next".
> I rather have given to be different from for, then given to be another alias for for/foreach.
My intention was to have a "foreach" variant without automatic aliasing of the variable...
> Changing the context means that you break given(@ARRAY).
Yep, it's too late to change "given" now ...
I still prefer avoiding "given/when" at least until I'm smart enough for smart match.
And passing lists of arrays is no problem with \(...)
DB<100> @a=1..3 DB<101> @b=4..6 DB<102> for (\(@a,@b)) {print} ARRAY(0xa3dcd78)ARRAY(0xa3dcc48) DB<103> for (\(@a,@b)) {print @$_} 123456
while "given" relies on magic:
So "given(@foo)" is the same as "given(\@foo)"
Cheers Rolf
|
|---|