in reply to Rexgrep

Uuuuhm dunno, I usualy use :
$Naam=(split /\//,$img)[-1];<BR>
Dunno if the split is expensive...

Replies are listed 'Best First'.
RE: Re: Rexgrep
by chromatic (Archbishop) on Apr 20, 2000 at 20:08 UTC
    Looks like it's slightly faster than the regexp:
    Benchmark: timing 1000000 iterations of regexp, split, substr... regexp: 16 wallclock secs (16.27 usr + 0.03 sys = 16.30 CPU) split: 17 wallclock secs (15.88 usr + 0.00 sys = 15.88 CPU) substr: 6 wallclock secs ( 5.32 usr + 0.00 sys = 5.32 CPU)
    Hmm, substr is the winner in a big big way. Makes sense. What if we anchor the regexp?         'regexp' => sub { my($file) = $img =~ m#.*/(.*)$# } gives us
    regexp: 17 wallclock secs (16.15 usr + 0.00 sys = 16.15 CPU) split: 15 wallclock secs (15.93 usr + 0.00 sys = 15.93 CPU) substr: 5 wallclock secs ( 5.37 usr + 0.00 sys = 5.37 CPU)
    Nothing else I tried improved things.