#!/usr/bin/perl use strict; use warnings; my $dir = shift // '.'; opendir my $dh, $dir or die "Could not open '$dir' for reading '$!'\n"; my @things = grep {$_ ne '.' and $_ ne '..'} readdir $dh; foreach my $thing (@things) { if($thing =~ /^test/){ print $thing . "\n"; } } closedir $dh or die "Could not close dir hanlde '$dh': '$!'\n"; __END__ Monks$ perl test.pl test.pl~ test.pl