Yes, I know what grep does... sorry. I was missing some of the programming
compactness stuff...
On Thu, 3 Jan 2002, Jeff 'japhy' Pinyan wrote:
> On Jan 3, Matthew Lyon said:
>
> >On Thu, 3 Jan 2002, Jeff 'japhy' Pinyan wrote:
> >
> >> I'd use grep():
> >>
> >> @compressed = grep length, @array;
> >>
> >> That only allows elements with a non-zero length to get through.
> >
> >wait! how does this grep trickery work? where's the circuitry?
>
> Uh... it's what grep() does. My code is the same as the slightly more
> verbose:
>
> @compressed = grep { length($_) != 0 } @array;
>
> which means "all those elements whose length is not zero." First, I left
> out the argument to length(), which assumes $_ if no argument is given.
> Second, I used the return value of length() as a true-false value -- if
> length() returns some that's not zero, that value is true. Third, I often
> use the grep(EXPR, LIST) format, instead of grep(BLOCK LIST).
>
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]