in reply to Re: regex problem!
in thread regex problem!

Question:
Could it be that
($name) = split /-\d/,$string,2;
is more efficient regarding time and/or memory than your solution?

Just wonder because I thought that this will just split into two array elements, thus saving some memory (maybe) but at least some time.

Replies are listed 'Best First'.
Re: Re: Re: regex problem!
by antirice (Priest) on Jul 18, 2003 at 11:38 UTC

    Yes, it is.

    Benchmark: running mine, yours for at least 3 CPU seconds... mine: 3 wallclock secs ( 3.03 usr + 0.00 sys = 3.03 CPU) @ 27 +8704.16/s (n=844822) yours: 3 wallclock secs ( 3.13 usr + 0.00 sys = 3.13 CPU) @ 34 +5612.45/s (n=1082739) Rate mine yours mine 278704/s -- -19% yours 345612/s 24% --

    antirice    
    The first rule of Perl club is - use Perl
    The
    ith rule of Perl club is - follow rule i - 1 for i > 1