perl -MFile::Basename -e 'print join ":", fileparse("foo.bar.baz", "\\.[^.]+"), "\n"'