use strict; use warnings; while () { chomp; my @parts = split /\./; pop @parts; my $file_no_ext = join '.', @parts; print "file_no_ext = $file_no_ext\n"; } __DATA__ foo.bar.txt goo.doc boo.hoo.moo