Lost Password?

Go Back   CodeCall Programming Forum > Web Development Forum > Perl

Perl Discussion for the PERL language - Practical Extraction and Reporting Language, is a programming language often used for creating CGI programs.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-06-2008, 04:41 AM
noobjason noobjason is offline
Newbie
 
Join Date: May 2008
Posts: 1
Rep Power: 0
noobjason is on a distinguished road
Default Perl Programming: Pack()..bit of hex

hi,

I am trying to learn more about binary formats and their lay-outs, so I can become a better coder, more advanced in just programming 'hello worlds' and simple programs. So I started to write some small scripts just for this purpose (rather to be called small pieces of junk code to achieve my goals), to examine my compiled hello world binaries. I have some minor C and Perl programming experience, but for this I prefer perl, because well... its easier for me to understand at this point.

I am able to read in my "binary" file, using, true normal I/O (open FILE), read it and print this information using a formatted string (printf '%#x', $myFile) to give a hexadecimal representation. Now with that script I am able to direct my binary file to an output file (which works quite fast) by doing something like this:

$ perl myn00bscript -f myhelloworld.bin > hexadecimal.txt

The output I have is like:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x2c 0x9 0 0x2 0 0 0 0x2 0x8ae 0x8ae 0x8ae 0x8ae 0x8ae 0x8ae 0x8ae 0x8ae 0x8ae 0x8ae 0x8ae 0x8ae 0x16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 <and so on>

Now here comes my n00bish question. If I want to convert this file back to binary, how can I do this using split, hex and pack? Or are there better ways? Please do elaborate with some code snippets, I have Googled and found many, many usefull resources only I lack programming experience to tackle this. I thank you!

Ofcourse I can just use a hex-editor, but as I told before, it's about learning here.

-Jason
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
What should I do next....(general programming) InfiniteSpawn General Programming 26 04-17-2008 02:34 PM
General programming and logic :: Programming language types Chinmoy Tutorials, Classes and Code 1 04-07-2008 03:15 PM
General programming and logic Chinmoy Tutorials, Classes and Code 0 03-20-2008 04:58 AM
Beginning Programming frank_l C and C++ 11 10-11-2007 02:23 AM


All times are GMT -5. The time now is 11:46 PM.

Contest Stats

No contest at this time. Please check back later.

Ads