Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: New to Perl

by jrtayloriv (Pilgrim)
on Jun 23, 2010 at 21:05 UTC ( #846176=note: print w/replies, xml ) Need Help??


in reply to New to Perl

Also, if you are trying to grab lines based on the number of fields, you could do:

do_something_with($line) if (@{[split / /, $line]} == 3);

... to grab all of the lines that have 3 fields in them.

The following is a little faster, but throws a warning:

do_something_with($line) if ((scalar split / /, $line) == 3);

Of course, if you are looking at more than the number of fields, these won't be useful ...
--jrtayloriv

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://846176]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2020-12-02 18:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you use taint mode?





    Results (44 votes). Check out past polls.

    Notices?