Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: skipping the first line of a file

by citromatik (Curate)
on Jun 12, 2009 at 21:45 UTC ( #771115=note: print w/ replies, xml ) Need Help??


in reply to Re: skipping the first line of a file
in thread skipping the first line of a file

my $discard = <$fh> for 1 .. 1; # $discard no longer in scope here.

I don't get the point, in what sense is your example better than this?

<$fh>;

or

<$fh> for 0..2;

The diamond operator doesn't use $_ as default, so using it in "void" context silently reads the next line of the filehandle

citromatik


Comment on Re^2: skipping the first line of a file
Select or Download Code
Re^3: skipping the first line of a file
by johngg (Abbot) on Jun 12, 2009 at 22:44 UTC
    silently reads the next line

    I use $discard to make it more obvious that the return value of the readline is being thrown away.

    Cheers,

    JohnGG

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (9)
As of 2015-07-06 09:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (70 votes), past polls