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

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

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

"5.ae.20.b.1c.7"

(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:

"05ae200b1c07"

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.

Odud