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


in reply to One for the regexp fans

Do MAC addresses always have six sections? If so, you could do something like this:

my $fmt = '%02x' x 6; $mac = sprintf $fmt, map hex, split /\./, $mac;

It's still two lines, but the first is just there so I don't have to type '%02x' six times :)

Oh, and it's not really a regex solution - sorry!

--
<http://www.dave.org.uk>

European Perl Conference - Sept 22/24 2000, ICA, London
<http://www.yapc.org/Europe/>