in reply to read the whole folder files

So close. opendir/readdir is the equivalent of ls or dir; it just lists the directory content. Assuming you want to read the contents of the file, you need to open them, too, a la:

foreach my $file (@files) { next unless -f "$directory/$file"; open my $fh, '<', "$directory/$file" or die "Open failed on $file: + $!"; while (<$fh>) { next if /^\s$/; # skip blank lines

Also note the use of -f to check that you're dealing with an ordinary file before opening and actually testing that the file open worked.

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.