in reply to Newbie: parentheses, map, etc.
It's not working because s/// returns the number of replacements that it did, not the string after replacement. If you want that, you can say map { s/.../.../; $_ } @stuff. Note, however, that this modifies the original list. Since you're modifying the values in place anyway, you might as well use a for loop instead.
s/(.*)/ $1\n/ for @small_files;
The error you get without the parentheses on grep is (at least when I tried it):
Warning: Use of "-s" without parentheses is ambiguous Unterminated <> operator
You can disambiguate -s by putting $_ in the expression explicitly.
my @small_files = grep -s $_ < 10_000, @ARGV;
Otherwise, it thinks that you were going to say something like -s <STDIN> but forgot the closing >.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Newbie: parentheses, map, etc.
by nefigah (Monk) on Mar 04, 2008 at 03:57 UTC | |
by kyle (Abbot) on Mar 04, 2008 at 05:10 UTC |