Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^4: move down 2 lines in file?

by johngg (Canon)
on Jul 11, 2008 at 22:13 UTC ( [id://697105]=note: print w/replies, xml ) Need Help??


in reply to Re^3: move down 2 lines in file?
in thread move down 2 lines in file?

Yes, you could do it like that:-

my $linesToSkip = 2; while ( <FILE> ) { next if 0 < $linesToSkip --; # Do something here with the lines of interest. ... }

I'd rather segregate the discarding of header lines (or whatever) from the processing of lines I'm interested in.

my $linesToSkip = 2; my $discard = <FILE> for 1 .. $linesToSkip; while ( <FILE> ) { # Do something here with the lines of interest. ... }

I hope this is of interest.

Cheers,

JohnGG

Update: Fixed typo.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-04-25 08:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found