where the letter pairs represent hexadecimally-encoded octets. Sometimes however a script will be passed a Cisco-style address:aa:bb:cc:dd:ee:ff
or even worse, something copied and pasted from a Windows dialog box:0001.0203.0405
The one-liner below converts incoming MAC addresses in (almost) any format into the desirable form, with octets separated by colons. The MAC to be filtered is in $_.00-01-02-03-04-05
This could of course be cleaned up, using a qr// to avoid duplicating the hex-octet identifier.
s/([0-9a-f]{2})[^0-9a-f]*/$1:/ig;chop;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: MAC Pretty-printer
by thor (Priest) on Jan 21, 2005 at 04:37 UTC | |
by moot (Chaplain) on Jan 27, 2005 at 01:33 UTC |