#!/usr/bin/env perl # grab the extension from a filename use strict; use warnings; use File::Basename; foreach (@ARGV) { my ( $name, $path, $suffix ) = fileparse( $_, qr/\.[^.]*/ ); # remove leading period $suffix =~ s/^\.(.*)/$1/; print $suffix . "\n"; }