($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'