Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

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,

  • Comment on Re: Split files into chunks of $n lines

Replies are listed 'Best First'.
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. :)


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://495425]
[jedikaiti]: Hi Monks

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (12)
As of 2017-10-23 15:58 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (280 votes). Check out past polls.