Assuming you have files that can be read line-by-line, as the directory name indicates log files:
use strict;
use warnings;
use autodie;
my $DIR = '/home/aimanhalim/LOG';
chdir $DIR;
opendir my $dh, $DIR;
while (my $entry = readdir $dh) {
next if $entry =~ /^[.]/; # skip the '.' and '..' entries and hidden files
if (-f $entry) { # skip entries that are not files
open my $fh, '<', $entry;
while (my $line = $fh->getline) {
# do something with the content
}
}
}
If you want to read directories recursively, perhaps switch over to Path::Tiny.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…