@files includes (I'd like to match all of these): "__asdf.jpg asdf.jpg FOO.AVI Hjz-6Nj.JPG this is[myfile].jpg" foreach my $file( @files ) { # I've tried various "character classes (w, W, d, D...), # combinations of anchoring, not anchoring, using + # I'm not getting consistent matches. At best the below # gives me most files but Hjz-6Nj gets "$1 = Hjz" I lose # the hyphen. # # And for $2, when I have a list of extensions like this # is there a sort of array I can place them in? And # what about camel case extensions? This long list seems # really innefficent. if ( $file =~ /(\w+|W).(jpg|JPG|gif|GIF|wmv|WMV|mpg|MPG|avi|AVI)$/ ) { my $prefix = $1; my $ext = $2; print "prefix: [$prefix]\n"; print "ext: [$ext]\n"; } }