Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
more useful options
 
PerlMonks  

Rea: How to populate an Array

by baku (Scribe)
on Dec 06, 2001 at 02:03 UTC ( #129774=note: print w/ replies, xml ) Need Help??


in reply to Re: How to populate an Array
in thread How to populate an Array

Or, try perldoc grep...

Perhaps something like:

@Y = grep { $_ =~ /^magic/ } (<R>);

That is the  grep EXPR LIST form of grep, which is exactly designed to search a list (here, the list of all records from filehandle <R>, split on the character or fixed length assigned to $/, q.v. in  perldoc perlvar ) and return only the elements of the list (here, records in the file; probably lines, if you leave $/ at its default of "\n") that give "true" values for the EXPR.

Oh, and you really should run through perldoc or at least the Llama...


Comment on Rea: How to populate an Array
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (8)
As of 2014-04-21 08:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (492 votes), past polls