Odud has asked for the wisdom of the Perl Monks concerning the following question:

I have a variable that contains, for example, the following:


(If you're curious it represents the MAC address of a LAN card).
What I want to do is to turn it into the following format:


i.e. remove the dots and add leading zeroes where the original was only one hex digit. After some experiments I came up the following snippet:
($mac = $addr) =~ s/(\.|^)([0-9a-f])(?=\.|$)/${1}0$2/g; $mac =~ s/\.//g;
This works, but I was wondering if there is a neater way - and in particular can it be done in a single statement?

As usual I look forward to everyone's contributions and suggestions.