Writing hex characters to file

Posted on 2000-03-14
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?
Question by:Aphroditus
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
LVL 10

Expert Comment

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


this will print out the hex value of number. so just print your hex value to a file

$buffer = sprintf("%lx",$number);
print FILEHANDLE $buffer;

will print your hex to the file FILEHANDLE
LVL 84

Expert Comment

ID: 2616861
Or do you mean you want
  print FILEHANDLE "\x00";

Author Comment

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'...

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.


Author Comment

ID: 2619197

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

Expert Comment

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

Author Comment

ID: 2619342

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 :


LVL 84

Accepted Solution

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

Author Comment

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

thanks ozo!

Featured Post

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

In this tutorial I will focus on how to use WhizBase as a tool for sending ICQ messages to ICQ. Here I will use a new technology in WhizBase, published in WhizBase 5.1 version. In this tutorial I will use 3 files, pager.wbsp for the processing, e…
This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you mig…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

691 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