Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: String to hex

by trizen (Hermit)
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 pondering the Monastery: (14)
As of 2015-07-06 20:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (83 votes), past polls