Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: String to hex

by trizen (Friar)
on Aug 09, 2012 at 14:20 UTC ( #986532=note: print w/ replies, xml ) Need Help??


in reply to String to hex

use strict; use warnings; my $text = "COM7:"; my @pairs = unpack "(A2)*", uc unpack "H*", $text; for (my $i = 0 ; $i <= $#pairs ; ++$i) { printf "0x%02s%02s\n", reverse $pairs[$i] || 0, $pairs[++$i] || 0; } print "0x0000\n"; # :-) __END__ 0x4F43 0x374D 0x003A 0x0000


Comment on Re: String to hex
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (11)
As of 2014-11-28 23:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (200 votes), past polls