Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
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.


Comment on Re^2: Port Java code to Perl help
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://965053]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2014-08-23 12:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (173 votes), past polls