super geek question

C. Abney cabney at cyberpass.net
Sun Feb 6 23:10:06 CST 2000


~sdpm~
On Sat, 5 Feb 2000, Eugene Tsyrklevich wrote:

> btw, your last benchmark item is broken. you say $f[$i]=~ /(\S+$)/;  
> that applies the regular expression to $f[$i] and then it throws away
> the result. to fix that you can say
> $f[$i] = $1 if $f[$i] =~ /(\S+$)/;
> 
> or you can do it the perl way :)
> 
> push @f, /(\S+$)/  for @fl;
> 
> ^ that should be a bit faster than your original loop since for (@fl) is
> faster than for ($i=0; $i<@fl;$i++) which is generally faster than using map

But doesn't that only work if you are populating a new array?  I liked the
parsimony of overwriting the existing values with the result.  I thought it
was appropriate for a one-time use of the array, and thought the extra memory
usage incurred pushing into a new array was... inelegant for a one-time use
like this. I would gladly exchange a little memory for performance, however.

Thanks for the tips... I'm going to sit down and read this copy of Mastering
Regular Expressions, and other things.  I've been thinking how well I've
been doing, but see now it is mostly an illusion brought on by reading the
code I'm assigned to maintain/rewrite. <g>

CA
-- 
You are responsible for the predictable consequences of your actions.
 -- Noam Chomsky                                                   C. Abney

~sdpm~

The posting address is: san-diego-pm-list at hfb.pm.org

List requests should be sent to: majordomo at hfb.pm.org

If you ever want to remove yourself from this mailing list,
you can send mail to <majordomo at happyfunball.pm.org> with the following
command in the body of your email message:

    unsubscribe san-diego-pm-list

If you ever need to get in contact with the owner of the list,
(if you have trouble unsubscribing, or have questions about the
list itself) send email to <owner-san-diego-pm-list at happyfunball.pm.org> .
This is the general rule for most mailing lists when you need
to contact a human.




More information about the San-Diego-pm mailing list