opendir THEDIR, "$basepath$ARGV[0]" || die "Unable to open directory: $!"; @allfiles = grep /^2/,readdir THEDIR; closedir THEDIR; $numfiles = @allfiles; $numfiles = ($numfiles - 2); foreach $file (sort { ($b) <=> ($a) } @allfiles) { if (-T "$basepath$ARGV[0]/$file") { $passflag = 0; open THEFILE, "$basepath$ARGV[0]/$file"; ($ref, $cust, $email, $phone, $mobile, $posted) = ; close DATAFILE; chomp($ref, $cust, $email, $phone, $mobile, $posted); $file =~ s/\.DAT//; print"$ref$cust$email$phone$posted\n " unless ($passflag); print "\n"; }}}