opendir( DIR, $targetdir ) || die $!; my @files = grep{ /\.sf$/ } readdir( DIR ); ## do interesting stuff with @files