in reply to Use 'ls' to read files in perl????
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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Use 'ls' to read files in perl????
by ad23 (Acolyte) on Jul 07, 2010 at 21:08 UTC |