[Israel.pm] A regexp question
ishay at checkpoint.com
Sun May 16 20:44:41 PDT 2004
The question is not how to do it in another way - like in everything there are many ways to do the same action. The question is why
the global flag does not work in this regexp...
From: perl-bounces at perl.org.il [mailto:perl-bounces at perl.org.il] On Behalf Of Oron Peled
Sent: Sunday, May 16, 2004 7:18 PM
To: ishay at checkpoint.com; Perl in Israel
Subject: Re: [Israel.pm] A regexp question
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?
Perl mailing list
Perl at perl.org.il
More information about the Perl