use File::Basename; my @suffix = qw(txt html foobar); my $string = '/path/to/foo.bar.foobar'; my ($file,$path,$ext) = fileparse($string,@suffix);