in reply to Confusing grep behavior
my @res = grep $_ split(",", "a,b,c,d,,f,,h"); #is a syntax error.
According to the POD when grep is not called with a block it requires a comma before the list you are working on.
grep EXPR,LIST
So this will work as you expect.
my @res = grep $_, split(",", "a,b,c,d,,f,,h");
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Confusing grep behavior
by dextius (Monk) on Dec 04, 2007 at 23:33 UTC | |
by perrin (Chancellor) on Dec 04, 2007 at 23:52 UTC | |
by dextius (Monk) on Dec 05, 2007 at 00:44 UTC | |
by grep (Monsignor) on Dec 05, 2007 at 00:44 UTC |