- or download this
if ($img =~ m#.*/(.*)#) {
$name = $1;
...
else {
# didn't match!
}
- or download this
use Benchmark;
...
'regexp' => sub { my($file) = $img =~ m#.*/(.*)# },
'substr' => sub { my $file = substr $img, rindex($img, '/') + 1 }
});
- or download this
Benchmark: timing 1000000 iterations of regexp, substr...
regexp: 11 secs (11.18 usr 0.00 sys = 11.18 cpu)
substr: 4 secs ( 5.67 usr 0.00 sys = 5.67 cpu)