Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^2: Port Java code to Perl help

by Eliya (Vicar)
on Apr 14, 2012 at 09:34 UTC ( #965053=note: print w/replies, xml ) Need Help??


in reply to Re: Port Java code to Perl help
in thread Port Java code to Perl help

As pack 'H' is working from left to right on the passed string, you can simply say pack 'H2' (two hex characters make up one byte):

sub get_bytes { return join '', map { pack('H2', $_) } split /-/, $_[0]; } print get_bytes('66-6f-6f00-62ff-61-72');

This would print "foobar", because the lower bytes 00 and ff are being ignored.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://965053]
help
Chatterbox?
[stevieb]: I have learned that my daughter has significant brain injury, so that's affecting my decisions. Don't know who to reach out to. I just want to vent. I am honestly lost. It's something I can't code around.
[stevieb]: I am infuriated at the same time I am hopeless. It appears there are approaches to 'fix' things, but, you know..,

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (7)
As of 2017-02-25 04:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (365 votes). Check out past polls.