in reply to Building ARRAY with grep expression NOT working

if($String =~ '[^/]*\.js')

this is not wrong at all but just to clarify that the use of single quotes as regex delimiter is special in that it does not interpolate any variables inside the regex prior to matching:

my $ext = "js"; my $String = "abc.js"; print "ok" if($String =~ '[^/]*\.$ext'); # or: print "ok2" if($String =~ m=[^/]*\.$ext=); # or: print "ok3" if($String =~ m"[^/]*\.$ext"); # or: print "ok4" if($String =~ m![^/]*\.$ext!); # or: print "ok5" if($String =~ m{[^/]*\.$ext});

by prepending the regex with m you can use almost any symbol for delimiting, like {} or # etc. (edit: added some example delimiters)