ralph wrote:
Presumably, to avoid run time errors, that
would need to be something like:
push (/foo/ && @foo ||
/bar/ && @bar ||
/zap/ && @zap ||
@void), $_ for @source;
True.
Why not:
part ( @source, /foo/ => @foo, /bar/ => @bar, /zap/ => @zap );
Because C<map>, C<grep>, C<reduce> etc all take the list they're
operating on as the last argument. And they do that for a very good reason:
so it's easy to build up more complex right-to-left pipelines, like:
(@foo, @bar) :=
part [/foo/, /bar/],
sort { $^b <=> $^a }
grep { $_ > 0 }
@data;
@source -> /foo/ => @foo, /bar/ => @bar, /zap/ => @zap;
Huh???
That's the equivalent of:
@source, sub (/foo/ => @foo, /bar/ => @bar, /zap/ => @zap);
which is just a syntax error.
To end up with @foo entries being *aliases* of
entries in @source. Btw, could these be valid,
Err. I very much doubt it.
Damian