Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: reading file into an array

by johngg (Canon)
on Dec 05, 2008 at 22:16 UTC ( [id://728402]=note: print w/replies, xml ) Need Help??


in reply to Re: reading file into an array
in thread reading file into an array

Processing line by line in a while loop is a a more scaleable solution but I would prefer to separate the line skipping part from the main line processing logic. I think it keeps things clearer but others may disagree.

my $linesToSkip = 14; my $discard = <$file> for 1 .. $linesToSkip; while( my $line = <$file> ) { chomp $line; ... }

Calling the scalar $discard makes it clear that it is something we are not interested in whereas $line might be something we want to work with.

I hope you find these thoughts of interest.

Cheers,

JohnGG

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (9)
As of 2024-04-23 09:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found