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 (Chaplain)
on Mar 20, 2013 at 17:03 UTC ( [id://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($_); '

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-24 22:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found