my $file = "test.exe"; # Match a dot,followed by any number of non-dots until the # end of the line. my ($ext) = $file =~ /(\.[^.]+)$/; print "$ext\n";