I have a huge file of size say 18MB or more i need to split the files to seperate files of say 800KB using Perl
File 1 - 500MB (This should have first part of the orginal file)
File 2 - 500MB (This should be the continuation of the File1)
so on....
Thank you
Eby
I have a text file of 18 MB i need to split the files to sizes of 800 KB each, using Perl?
I don't think there is anything in native perl that can do this, unless you read the whole file in and then it wrote it back out in parts (would probably have to be a length of characters, which would roughly translate to file size)
other option: most compression programs have a split funciton which allows you to break it up.. not sure if this is an option
Reply:If it's a "text" file, just open it, read line-by-line, keep track of how much you've read, write to output file. When you reach limit, switch to next output file.
If it's a "binary" file, you can do the same thing using sysread.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment