Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
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 chilling in the Monastery: (9)
As of 2014-09-22 06:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (182 votes), past polls