Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Split files into chunks of $n lines

by kirbyk (Friar)
on Sep 27, 2005 at 15:56 UTC ( #495425=note: print w/ replies, xml ) Need Help??


in reply to Split files into chunks of $n lines

If you're in unix, use the 'split' command. I think the syntax would be 'split -l 4000 filename', and it will do exactly what you want. (See man split for more detail.)

It's not tremendously hard to do it through perl, and if you want to modify anything that'd be useful. I'm sure someone will post code for that very soon. There's more than one way to do it!

-- Kirby, WhitePages.com


Comment on Re: Split files into chunks of $n lines
Re^2: Split files into chunks of $n lines
by Kanji (Parson) on Sep 27, 2005 at 17:18 UTC

    Even if you don't use Unix (or do but are missing the split command), you can download a pure-Perl implementation of split from the Perl Power Tools site. :)

        --k.


Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (9)
As of 2014-10-01 09:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (3 votes), past polls