http://www.perlmonks.org?node_id=572399


in reply to Regex overlap in MAC address

Personally, I prefer your second approach over the regex approach. I would make it a little more brief with sprintf, something like this:

my $mac_pad = join(':' => map { sprintf "%02s", $_ } split(/:/, $mac));
You could argue that it's too compact, but I think the join-map-split idiom is fairly common. YMMV.