I have found the code for read all the text file in a directory. But I don't know how to find the commonality between them. Please help me with the code, or share on what area I need to explore more. There is too much to learn but I have a time constraint.
use strict;
use warnings;
use English;
my $dir = 'C:\Perl_Example\Data';
foreach my $fp (glob("$dir/*.txt"))
{
printf "%s\n", $fp;
#the file header
open my $fh, "<", $fp or die "can't read open '$fp': $OS_ERROR";
#open file to read which is each file in dir
while (<$fh>)
{
printf " %s", $_;
#print the file content
}
close $fh or die "can't read close '$fp': $OS_ERROR";
}