Is there a regular expression in Perl to find a file's extension?

perl

Solution

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";

Problem

Is there a regular expression in Perl to find a file's extension? For example, if I have "`test.exe`", how would I get the "`.exe`"?

Original source