in reply to Re^2: Parsing a tab delimited file
in thread Parsing a tab delimited file
with@molecules = <MOL>; map { chomp; $_ = quotemeta; } @molecules;
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.push my @molecules, quotemeta chomp while <MOL>;
I just recently tried this sort of approach in an attempt to shorten a one-liner, and didn't get what you expect:
Yields:push @m, quotemeta chomp while <DATA>; print join("|",@m),$/; __DATA__ AAA BBB &*(
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 |