Grep and list notation
by Lyle Kopnicky other posts by this author
May 20 2005 3:14PM messages near this date
view in the new Beta List Site
Re: Grep and list notation
|
Re: Grep and list notation
Suppose you want to take a list of lines, and filter out just the ones
where the third field exceeds 100. This works:
@OutLines = grep { my @f = split / +/, $_; $f[2] > = 100 } @InLines;
My question is, why can I not simplify it, eliminating the temporary @f
variable, like this:
@OutLines = grep { $@{split / +/, $_}[2] > = 100 } @InLines;
I keep getting this error about "uninitialized value in numeric ge". If
I understand correctly, putting @{ } around the split should let me
group it so I can use the $...[] notation to subscript it. Apparently I
misunderstand.
Does anyone know how I can properly write this as an expression, without
needing the intermediate variable?
Thanks,
Lyle Kopnicky
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Lyle Kopnicky
$Bill Luebkert
David Vergin
|