Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
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 chilling in the Monastery: (7)
As of 2014-07-12 06:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (238 votes), past polls