Hello all, I came across this problem opening up files that are fed in
from command line using "ls". I do not know why this script did not
work. Appreciated any input.
#!/usr/local/bin/perl
# I am trying to feed all the files in this directory to do text
processing and save the processed txt into an #output called outout.txt
while ($LINE = <STDIN>) {
chomp $LINE;
open (AFILE, "$LINE") or die ( "cannot open $LINE");
open X, ">>output.txt";
while ($LINE1 = <AFILE>) {
$LINE1 =~ s/^\s*//;
print X "$LINE1";
}
close X;
close AFILE;
}
at prompt I typed
ls *.txt | perl format.pl
it never worked!!!! it always "die" cannot open $LINE. I don't
understand why
thanks
-jen