Solved

Writing hex characters to file

Posted on 2000-03-14
8
231 Views
Last Modified: 2013-12-25
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?
0
Comment
Question by:Aphroditus
  • 4
  • 3
8 Comments
 
LVL 10

Expert Comment

by:makerp
ID: 2615341
$number = hex("ffff12c0");

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
0
 
LVL 84

Expert Comment

by:ozo
ID: 2616861
Or do you mean you want
  print FILEHANDLE "\x00";
?
0
 

Author Comment

by:Aphroditus
ID: 2619146
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?
0
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 

Author Comment

by:Aphroditus
ID: 2619197
ozo,

that won't work, cos it would write SCALAR("xxxxxxxx") to the file and that is not what we want
0
 
LVL 84

Expert Comment

by:ozo
ID: 2619243
What do you mean by SCALAR("xxxxxxxx")?
0
 

Author Comment

by:Aphroditus
ID: 2619342
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(0x80512cc)

0
 
LVL 84

Accepted Solution

by:
ozo earned 50 total points
ID: 2619372
#I said
  print FILEHANDLE "\x00";
#not
  print FILEHANDLE \x00;
0
 

Author Comment

by:Aphroditus
ID: 2619386
gee... didn't notice that one!
anyway, it worked! didn't know the solution was so simple!

thanks ozo!
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Nmap how to find wich type of socks is this? 4 106
Need to Modify a Script I found 5 107
React or Angular? 6 79
Rename all files in a directory to numerical order 26 28
This tutorial will discuss the log-in process using WhizBase. In this article I assume you already know HTML. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you might look at some of my other articles abo…
Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question