<?xml version="1.0" encoding="windows-1252"?>
<node id="26229" title="(Adam: JoinMapSplit) RE: One for the regexp fans" created="2000-08-04 16:55:41" updated="2005-08-09 00:17:10">
<type id="11">
note</type>
<author id="9135">
Adam</author>
<data>
<field name="doctext">
&lt;code&gt;
$mac = join '', map { /^([0-9a-f])$/i ? "0$1" : $_ } split /\./, $addr;
&lt;/code&gt;
The nice thing about perl is that it allows you to code in a manner that simulates speech. You said something like, "I want to split up the address at the dots, prefix zeros to single digit hex values, and join it all together to make a value." Which, incidentally, is exactly what the above one-liner does.</field>
<field name="root_node">
26155</field>
<field name="parent_node">
26155</field>
</data>
</node>
