my $n = 'foo.bar.txt'; $n = substr $n, 0, rindex( $n, q{.} );