Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 224
  • Last Modified:

can I output integer data in binary form rather than ASCII?

I am processing some data with perl. I need to output my integer data in 2-byte signed (i.e., -32768 to +32768) binary format rather than standard ascii text format. [i.e., analogous to outputing data with the write() C-language command available from unistd.h]. I don't want to have any end-of-line characters between each integer value. Is there a way to do this in perl?
Thanks, Dave
0
djc2
Asked:
djc2
  • 4
  • 3
1 Solution
 
ozoCommented:
pack('s',32768) #a signed short value
pack('n',32768) #a short in "network" (big-endian) order
pack('v',32768) #a short in "VAX" (little endian) order
0
 
djc2Author Commented:
OK that works ... I guess it wasn't as difficult a question as I thought. Thanks. So how do I give you a grade?
0
 
ozoCommented:
What grade do you want to give?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
djc2Author Commented:
So whether or not you tell me how to give you a grade depends on what the grade is, huh? (just kidding) ... A

In the past I thought that I was always given the option to give a grade. Has the system changed?
0
 
ozoCommented:
The system hasn't changed.  I just wanted to be sure you got everything you needed before locking the question
0
 
djc2Author Commented:
OK, thanks.
0
 
ozoCommented:
You're welcome.
perldoc -f pack
should tell you about other pack/unpack formats that may be useful
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now