ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl-win32-users
perl-win32-users
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

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved