Michael G Schwern wrote:
> and that's just entirely too much work. I'd love to be able to do
> it with a grep like thing.
>
> (@switches, @args) = seperate /^-/, @ARGV;
>
> seperate() simply returns two lists. One of elements which match,
> one of elements which don't. I think Perl 6 will allow the above
> syntax to work rather than having to play with array refs.
>
It would be nice to make it work with more than two arrays too.
Something like this:
(@upper, @lower, @mixed) = @array.sep {
when /^[A-Z]*$/ {0}
when /^[a-z]*$/ {1}
default {2}
}
But it looks a bit dangerous, because the following won't work if
@array has numbers in it:
(@false_members, @true_members) = @array.sep { $_ }; # bad
Maybe the solution is to make it hash-wise:
%hash = @array.sep {
when /^[A-Z]*$/ {'uppercase'}
when /^[a-z]*$/ {'lowercase'}
default {'mixedcase'}
}
-angel