Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^3: Help me decipher code containing map function

by AnomalousMonk (Archbishop)
on May 23, 2017 at 17:09 UTC ( [id://1191001]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Help me decipher code containing map function
in thread Help me decipher code containing map function

I will take the liberty of answering for BrowserUk. I'm not sure what $packed1 and $packed2 are supposed to represent. If $packed1 is the original, raw MAC address and $packed2 is the reformatted address (with bytes represented as hex-digit pairs and with dots thrown in for good measure), then no, they cannot be directly compared:

c:\@Work\Perl\monks>perl -wMstrict -le "my $octetstr = qq{\x44\x69\x66\x66\x65\x72}; print qq{raw: '$octetstr'}; ;; my $mac = join '.', unpack '(H4)*', $octetstr; print qq{reformatted: '$mac'}; ;; if ($octetstr eq $mac) { print qq{'$octetstr' and '$mac' are equal}; } else { print qq{'$octetstr' and '$mac' are NOT equal}; } " raw: 'Differ' reformatted: '4469.6666.6572' 'Differ' and '4469.6666.6572' are NOT equal
(The two strings would have to be converted to a common format for comparison.)

If $packed1 and $packed2 are both reformatted MAC addresses (and they've both been reformatted according to the same scheme), then yes, they can be directly compared for equality.

Incidentally, this is another question that's open to resolution by direct experimentation. Could you not have written a couple of short routines to answer your own question — plus some variations?


Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-11-14 08:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    chatterbot is...






    Results (39 votes). Check out past polls.