in reply to Re: regex to return file extensions
in thread regex to return file extensions

When you are already using File::Basename to extract the filename, then the following is also an option
($name, $path, $suffix) = fileparse('/home/foo/bar.txt', qr{[^.]*}); # or if you have a list of allowed suffices in @suf @suf = qw/gif wav mpeg txt/; ($name, $path, $suffix) = fileparse('/home/foo/bar.txt', @suf); # both lead to # $name eq 'bar.' # $path eq '/home/foo' # $suffix eq 'txt'

-- Hofmator