[boulder.pm] unsubscribe

Jay Kominek Jay.Kominek at colorado.edu
Thu Jun 27 17:00:34 CDT 2002


On Thu, 27 Jun 2002, Keanan Smith wrote:

>    @{$me->{arrayrep}} = split(/(?=$me->{break})/,$value);
>    my $mypos = 0;
>    foreach $line (@{$me->{arrayrep}})

>     while ($value =~ /$me->{break}/g)
>     {
>       my $mypos = pos($value);

> I would think that the first (Which calls the 'split' builtin to generate
> the array)
> would be faster than the second (Which repeatedly does a regular expression
> and assigns the list elements by hand)

> But in fact it's the reverse! Weird eh?
> Anyone have a good explination for why?

You're allocating more memory for the first one, as well as using a zero
width assertion. If I recall correctly, those (can) significantly increase
the time it takes to perform a match. They'd certainly make it more
complex to repeatedly match a string.

The double indirection to access the elements of the array can't help
much, either. (Hopefully Perl is optimizing it away, but you never know.)

Any actual values for the change in algorithmic and constant time?

- Jay Kominek <jay.kominek at colorado.edu>
  Plus ça change, plus c'est la même chose





More information about the Boulder-pm mailing list