in reply to Re: Using substr to remove characters
in thread Using substr to remove characters

i still don't understand, why you're usiińg substr() at all - instead of a regex

Speed

$str =~ s/_(\.mp3)$/$1/g; # Or Much faster with the same result: substr($str, -5, 1, "") if(substr($str, -5, 1) eq '_');

If you do not need the power of metacharacters which a regex offers, don't use a regex. Using a regex for this opperation is like using a sledge hammer to pound in a small nail.


They say that time changes things, but you actually have to change them yourself.

—Andy Warhol