in reply to Re^2: Parsing a tab delimited file
in thread Parsing a tab delimited file

Thanks -- those are mostly good points... except there's a problem in the second item:
I'd replace
@molecules = <MOL>; map { chomp; $_ = quotemeta; } @molecules;
with
push my @molecules, quotemeta chomp while <MOL>;
The problem with this replacement is that chomp simply modifies its arg ($_ in this case), but does not return the modified arg -- something other than the chomp'ed string gets returned to quotemeta, and pushed onto @molecules.

I just recently tried this sort of approach in an attempt to shorten a one-liner, and didn't get what you expect:

push @m, quotemeta chomp while <DATA>; print join("|",@m),$/; __DATA__ AAA BBB &*(
Yields:
1|1|1

Maybe "map" in a void context isn't sexy, but it does work. (I agree that grep in a void context would be silly.)

Replies are listed 'Best First'.
Re^4: Parsing a tab delimited file
by particle (Vicar) on May 13, 2002 at 22:37 UTC
    you're right! i should have tested before posting. i still think map in void context is a bad idea, so i came up with this: my @molecules = map { chomp; quotemeta } <DATA>; ...but is it sexy enough ;-)

    ~Particle *accelerates*