#!/usr/bin/perl -w use strict; my $path = "C:/temp"; opendir (my $dirhandle, $path) || die "cannot open dir $path"; my @perl_files = grep {/.pl$/} readdir $dirhandle; print "@perl_files";