use URI::Escape; # or CGI.pm has an escape() function # also at the top of the script. my $pattern = quotemeta( lc( $ARGV[0] ) ); # in your loop if (my ($mp3) = /^