Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Print some lines in a range

by chuckbutler (Vicar)
on Mar 05, 2010 at 01:02 UTC ( #826852=note: print w/ replies, xml ) Need Help??


in reply to Print some lines in a range

There is a conflict between using command line option, switch, '-p' which sets up a loop around the '-e' code and using '@lines=<>' which reads the whole file(s), know as a slurp, into the list. A '-p' loop looks like:

LINE: while (<>) { #readline into $_; diamond operator ...<your '-e' code here>... } continue { print or die "-p destination $!\n"; }

Depending on what you are doing, the following may be better:

perl -pe "last if ($cnt > 50000);$_='' if ($cnt++ < 41900);" data02.lo +g > data03.log

This one-liner prints record 41900..50000, zero relative. It will end on record 50001, which should let you have the target file a little sooner.

Good luck. -c


Comment on Re: Print some lines in a range
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (10)
As of 2014-12-28 15:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (182 votes), past polls