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:
(The two strings would have to be converted to a common format for comparison.)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
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: <%-{-{-{-<
|
|---|