Backticks capture the output of an external command. In list context (as you have) they return a list of lines, and each of those lines ends in a linefeed (on *NIX platforms). You need to remove them using chomp:
my @files = `ls Data_files/*/Data.txt`; chomp @files;
or
foreach my $filename(@files){ chomp $filename;
In reply to Re: Use 'ls' to read files in perl????
by FunkyMonk
in thread Use 'ls' to read files in perl????
by ad23
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |