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

Re: Extract lines and output...

by jeroenes (Priest)
on Oct 10, 2001 at 00:09 UTC ( #117851=note: print w/ replies, xml ) Need Help??

in reply to Extract lines and output...

There are so many ways to do this. Maybe straightforward, don't print until $. is 4 (see perlvar):

while(<>){ next if $. <4; #codeblockdoingsomeotherthings print; }



Update: I couldn't resist adding some more possibilities:

#1 slurping the whole thing in memory, and splice @file = <>; splice @file, 0, 4; print @file; #2 using the flip-flop operator while (<>){ next unless $.>3 .. 1; #... print; } #3 another flip-flop $start = -3; while (<>){ next unless $start++ .. 1; #.... print; } #4 just repeat 4 times $dummy=<> for 1..4; #5 make it multifile proof while (<>){ close( ARGV) if (eof);  next unless $.>3 .. eof; #... print; }

Comment on Re: Extract lines and output...
Select or Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2015-11-30 00:08 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (754 votes), past polls