Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: Splitting a text file

by farang (Hermit)
on Mar 20, 2013 at 17:03 UTC ( #1024571=note: print w/ replies, xml ) Need Help??


in reply to Re: Splitting a text file
in thread Splitting a text file

Thanks, daxim, it was instructive to me to figure out how the pieces fit together. One thing though, your Perl code as written will put only 999 lines into the first file. This can be fixed by replacing $. with ($.-1)

</the/file perl -MIO::File -ne' my $nr = 1+int(($.-1)/1_000); $handles[$nr] = IO::File->new(sprintf("%05dNR.txt", $nr), "w") unl +ess defined $handles[$nr]; $handles[$nr]->print($_); '


Comment on Re^2: Splitting a text file
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2014-12-27 04:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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





    Results (176 votes), past polls