> foreach my $var (@arr) { ... }
You mean
foreach @arr -> $var {...}
> before { ... } # run before first iteration, only if there is at
> least one iteration
> after { ... } # run after last iteration, only if there is at least
> one iteration
> noloop { ... } # run if there are no iterations
I don't know. Seems like an awful lot of keywords to remember what a
simple if should take care of.
> between { ... } # run between iterations, not before first or after last
I usually find it better, for what you're talking about, to do something
after. That will be handled with C<NEXT>. But, for instance, when asking
for input I find myself asking something before the loop and at the end of
the loop. Technically, this should be in the condition of the while, but:
while print("Enter your input: "), $_=<> { }
Is quite yucky. So a feature to handle this might be nice.
Actually, because of the closure thing in Perl 6, could I do this?
while {
print "Enter your input: ";
$_ = <>
} { ... }
As far as I can tell, I can, which is I<very> nice :)
Oh, I seem to have strayed a little. Well, I guess, if you can do what I
just talked about, there's really not much need for your four extra
keywords.
It should be modulable, so you could write a nice module that would allow
us to C<use cool_loop_controls> :) This kind of breaks
the habit of CoolLoopControls, but I like breaking it in this
case. I think there's even a case in the camel book that describes
something like this, when talking about sub (&).
Luke