in reply to The right way to avoid an error

There appears to be an error in your code.
$mp3 =~ s/\./\\\./g;
inserts a backslash before the period in $mp3. But since $mp3 appears on the left side of a regexp that backslash will be a literal one. If $ARGV[0] includes a backslash, then inside the right-side of a regexp that backslash is a special character which merely turns the next character, but not the backslash itself, into a literal.

Thus,

if ($mp3 =~ /$ARGV[0]/i){
will always fail because anyfilename.mp3 will never appear in anyfilename\.mp3

Adding that backslash to $mp3 breaks the program.