Aphroditus
asked on
Writing hex characters to file
How do I output hexademical values to a file? I would like to include a 00 hex value at the end of a file in my server. What do I need to do in Perl to achieve this?
Or do you mean you want
print FILEHANDLE "\x00";
?
print FILEHANDLE "\x00";
?
ASKER
makerp, it does not mark the end of my file with the '00' hex when I viewed it with my hex editor. Instead, it had set it to '30'...
help?
help?
ASKER
ozo,
that won't work, cos it would write SCALAR("xxxxxxxx") to the file and that is not what we want
that won't work, cos it would write SCALAR("xxxxxxxx") to the file and that is not what we want
What do you mean by SCALAR("xxxxxxxx")?
ASKER
ozo,
lets say i set my cgi script to print the date to a file by using print FILEHANDLE &get_date;
then, when i add another print FILEHANDLE \x00(i want to add another 00 hex code after my date) , it would give me this in my file :
15-Mar-2000SCALAR(0x80512c c)
lets say i set my cgi script to print the date to a file by using print FILEHANDLE &get_date;
then, when i add another print FILEHANDLE \x00(i want to add another 00 hex code after my date) , it would give me this in my file :
15-Mar-2000SCALAR(0x80512c
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
gee... didn't notice that one!
anyway, it worked! didn't know the solution was so simple!
thanks ozo!
anyway, it worked! didn't know the solution was so simple!
thanks ozo!
will return the number value of the hex ffff12c0 which is 4,294,906,560
the inverse of this is
printf(lx",$number);
this will print out the hex value of number. so just print your hex value to a file
i.e
$buffer = sprintf("%lx",$number);
print FILEHANDLE $buffer;
will print your hex to the file FILEHANDLE