#!/usr/sbin/perl -w use strict; use Cwd; my $the_directory = cwd; #... chdir $the_directory or die "Couldn't chdir to $the_directory; $!"; opendir(D, ".") or die "Couldnt open . ($the_directory): $!"; while ($file = readdir D) { next unless $file =~ /\.las$/i; open(FILE, "$file") || warn "Warning: can't open $file, skipping.\n"; while () { chomp; #...