Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
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?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2017-08-21 16:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Who is your favorite scientist and why?



























    Results (324 votes). Check out past polls.

    Notices?