Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

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?

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2015-10-08 22:19 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (229 votes), past polls