[Israel.pm] A regexp question

Oron Peled oron at actcom.co.il
Sun May 16 09:18:17 PDT 2004


On Sunday 16 May 2004 18:15, Ishay Inbar wrote:
> just get the left value, for example from Solaris:
> 8:0:20:9f:22:78, where the first and the second couples start with 0.

Why not simply (not tested):
  @vals = split(/[:-]/, $mac);
  die "Bad value" if @vals != 6; # Optional sanity checking
  $mac = sprintf("%02x:%02x:%02x:%02x:%02x:%02x", @vals);

Havn't benchmarked, but at least it looks more robust to me.

-- 
Oron Peled                             Voice/Fax: +972-4-8228492
oron at actcom.co.il                  http://www.actcom.co.il/~oron

A physicist, an engineer, and a computer scientist were
discussing the nature of God.  Surely a Physicist, said the
physicist, because early in the Creation, God made Light; and you
know, Maxwell's equations, the dual nature of electro-magnetic
waves, the relativist consequences... An Engineer!, said the
engineer, because before making Light, God split the Chaos into
Land and Water; it takes a hell of an engineer to handle that big
amount of mud, and orderly separation of solids from
liquids... The computer scientist shouted: And the Chaos,
where do you think it was coming from, hmm?

---Anonymous




More information about the Perl mailing list