#!/usr/bin/perl -w use strict; #create file to write to open (LABNR, ">>Labnr_all.txt") or die "Could not open file"; #open the directory where files are located $dirname = 'Filer'; opendir (DIR, $dirname) or die "Could not open $dirname\n"; #count files $nrfiles = 0; while ($filename = readdir(DIR)){ $nrfiles ++ if $filename =~ /\.txt/; print "$filename\n" if -f $filename; #this is where I want to look into each file and extract the info... } print "The number of files in the folder: $nrfiles\n"; closedir(DIR)