Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing binary file to hex

Status
Not open for further replies.

niner710

Technical User
Aug 5, 2005
5
US
I want to change a 128MB binary file to Hex in perl. I would like the format to look like a hex dump.

Ex.
0000000: 30 30 30 30 30 30 30 3a 20 65 33 30 33 20 32 64 '0000000: e303 2d'
0000010: 39 33 20 36 34 63 36 20 36 36 38 36 20 66 66 36 '93 64c6 6686 ff6'
0000020: 33 20 30 31 65 63 20 63 38 36 34 20 32 64 64 63 '3 01ec c864 2ddc'
0000030: 20 20 2e 2e 2d 2e 64 2e 66 2e 2e 63 2e 2e 2e 64 ' ..-.d.f..c...d'
0000040: 2d 2e 0d 0a 30 30 30 30 30 31 30 3a 20 62 31 65 '-...0000010: b1e'
0000050: 63 20 62 36 63 64 20 66 65 30 34 20 38 37 32 66 'c b6cd fe04 872f'

I know I can use other utilities like Hex Dump to do it but I want to be able to do it in Perl so that I can do everything within my script. I tried using unpack, but that doesn't give me the address of each line. Any suggestions would be greatly appreciated. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top