index.html foo.pl CGI.pm video.mpeg foo.pl~ #### .foo .bar #### my @names = qw/ index.html foo.pl CGI.pm video.mpeg foo.pl~ .bash_history .bash_rc /; foreach my $string ( @names ) { print "$string -> "; $string =~ s/(.+)\.[^.]+$/$1/; print "$string\n"; }