chdir $the_directory or die "Couldn't chdir to $the_directory: $!"; opendir(D, ".") or die "Couldn't open . ($the_directory): $!"; my @files = grep { /\.las$/ } readdir D; closedir D; foreach my $file (@files) { # whatever... }