in reply to How do I read the contents of each file in a directory?

#!/usr/local/bin/perl use strict; opendir(DIR, "."); my @files = grep/^\w+/, readdir(DIR); for (@files) { undef $/; open(IN, "$_") || die "Cannot open $_"; my $str = <IN>; print $str; close(IN); }

If you need to read only text file you can grep only .txt file. For eg: my @files = grep/.txt$/, readdir(DIR);