I was slurping an internal web page that contains MAC addresses as a 12 char hexadecimal string, e.g. 01fe9d8d68e7.
I wanted to format these strings in a more conventional representation, e.g. 01:fe:9d:8d:68:e7. And when I wrote this snippet, it worked perfectly the first time!
I don't think I could have written this 4 years ago. Reading Perlmonks all this time has improved my Perl immeasurably. So, thanks.
# $mac = '01fe9d8d68e7'; $mac = join( ':' => ($mac =~ /(..)/g) );
Back to
Cool Uses for Perl