http://www.perlmonks.org?node_id=928855


in reply to matching and backreferencing filenames

First of all '.' in your regex doesn't only match '.' but almost anything

If you have one filename per line and each starting at the beginning of the line, you don't need to constrain your search expression with \w, use the more general '.'

if ( $file =~ /(.+)\.(jpg|JPG|gif|GIF|wmv|WMV|mpg|MPG|avi|AVI)$/ )