Update: Juerd is correct in his post below. I made a mistake in my post regarding the split operator. I have corrected this.
Here is an example of File::Basename, applied to the current directory. This is not perfect, but should get you started.
#/usr/bin/perl -w
use File::Basename;
use strict;
my @files = <*>;
foreach my $file (@files) {
my ($name,$dir,$type) = fileparse($file,'\..*');
print sprintf("file= %30s", $name), sprintf(" ext= %10s", $type),
+"\n";
}
you can refine this by crafting a better regex as the second argument to fileparse. This module is overkill unless you are dealing with full filepaths. for a single directory you could just use
my($filename,$ext) = split(/\./,$file);
or something similar.