[PLUG] Re: Perl

Rogan Creswick creswick at gmail.com
Sat Jul 8 01:02:44 UTC 2006


On 7/7/06, Wil Cooley <wcooley at nakedape.cc> wrote:
> On Fri, 2006-07-07 at 13:41 -0700, Randal L. Schwartz wrote:
>
> > Well, whether you spell it as a plain character or a regex, it gets *turned*
> > *into* a regex.  For example,
> >
> >         @list = split ".", "127.0.0.1";
> >
> > probably doesn't do what you want, because Perl treats it *identical* to:
> >
> >         @list = split /./, "127.0.0.1";
> >


<snip>

> cmpthese -1, {
>     split_re_dot => sub { my @x = split /\./, $string_to_split; return; },
>     split_ch_dot => sub { my @x = split '.', $string_to_split; return; },
> };

Part of the reason you may be seeing such a difference in performance
is that those two commands don't do the same thing...  The second one
will split on every character, unless I'm mistaken.

--Rogan


>
> print "Timing splitting of '$string_to_split2'...\n";
>
> cmpthese -1, {
>     split_re_colon => sub { my @x = split /\:/, $string_to_split2; return; },
>     split_ch_colon => sub { my @x = split ':', $string_to_split2;  return; },
> };
>
>
> Wil
> --
> Wil Cooley <wcooley at nakedape.cc>
> Naked Ape Consulting, Ltd. <http://nakedape.cc>
>
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.4 (GNU/Linux)
>
> iD8DBQBErv7GJpn3uYWUEaoRAnpMAJ4ygTPJqZFWeGxZgHsSwUAN2Nf1zwCfZxiJ
> 5a+azieMvWICggvbQZNJ5q0=
> =TeWh
> -----END PGP SIGNATURE-----
>
>
> _______________________________________________
> PLUG mailing list
> PLUG at lists.pdxlinux.org
> http://lists.pdxlinux.org/mailman/listinfo/plug
>
>
>



More information about the PLUG mailing list