Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Hex String XOR

by Not_a_Number (Parson)
on Mar 12, 2012 at 09:05 UTC ( #959089=note: print w/replies, xml ) Need Help??


in reply to Hex String XOR

$a = 0xaabbcc; $b = 0x112233; printf '%X', $a ^ $b;

Replies are listed 'Best First'.
Re^2: Hex String XOR
by Marshall (Abbot) on Mar 12, 2012 at 09:21 UTC
    I think this is good as far as it goes, but I would assume that the OP wants to XOR some humongous things that cannot be represented as simple Perl numeric scalar values? In this case, use hex() function.
    my $x = "aabbcc"; my $y = "112233"; printf '%x', hex($x) ^ hex($y); #bb99ff
    This causes integer overflow if $x and $y are "too big".

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://959089]
help
Chatterbox?
[1nickt]: Corion I feel that way a lot when I look at the news...
[1nickt]: Brethren, I just noticed in the CPAN ticker Retry, which led me to Attempt, by Mark Fowler. Does anyone have experience with either of these utilities?
[Corion]: No. Back when I toyed with the idea, I found that writing the loop explicitly was usually less code than passing the configuration+ callback to the retrier...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (13)
As of 2017-05-24 12:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?