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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

unpack Binary Data

Status
Not open for further replies.

jerehart

Programmer
Jun 10, 1999
61
US
Hey,

I am working on a binary file and need to get certain values out of the file and be able to use them as readable values, hex or decimal. I was thinking un/pack can help me but not too sure. Here is my code:

open(INFO,&quot;<$file&quot;) || die &quot;Can't open $file: $!\n&quot;;
seek (INFO, $MemAddr,0);
if ( 4 != (read INFO, $mdsa, 4))
{
print qq?***ERROR!****\nCounld not read Start
Address, Concatination Stoped.\n?;
exit;
}
print OUTF1 $mdsa;
$MDSA = unpack (&quot;H&quot;,$mdsa)

if ($MDSA != $DefFileSize)
{
print qq? Wrong File Size\n Aborted\n?;
exit;
}
else { .....}

I print the binary data to a file, OUTF1, for testing and I am getting the correct data (I tell by an octal dump), but how do I use that data inside the script, with out od the output file?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top