split file with according to size

B

Babu

Hi,

I have a input file called temp.hex (163840 bytes) . Is there any
function in perl that does the file splitting with size of the file
information

tempA.hex(81920 bytes) and tempB.hex(81920 bytes)
or

tempA.hex(3840 bytes) and tempB.hex(16000bytes)

Thanks in advance

Sn
 
N

nolo contendere

Hi,

  I have a input file called temp.hex (163840 bytes) . Is there any
function in perl that does the file splitting with size of the file
information

tempA.hex(81920 bytes) and tempB.hex(81920 bytes)
or

tempA.hex(3840 bytes) and tempB.hex(16000bytes)

There's a Unix utility which does this. The name of the utility is,
oddly enough, split.

split -b 81920 <file>
 
J

Jürgen Exner

Babu said:
I have a input file called temp.hex (163840 bytes) . Is there any
function in perl that does the file splitting with size of the file
information

tempA.hex(81920 bytes) and tempB.hex(81920 bytes)
or

tempA.hex(3840 bytes) and tempB.hex(16000bytes)

No, Perl does not have a function with this functionality. It is a rather
special request and it would be odd, if Perl as a general purpose language
would provide a separate function for each and every uncommon file handling
request.
But is trivial to write your own. Just open() the source and target files,
read() as many bytes as you want to go into the first target file, print()
those bytes to the first target file, and then repeat read()ing and
print()ing for the second target file.

However I would just use the external split program instead. Why reinvent
the wheel after all?

jue
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top