ls format is OS dependant. On Solaris ls returns a multiple column list, so the first 
line would be multiple filenames.

Chris D. Garringer
LAN/WAN Manager
Master Certified Netware Engineer
Microsoft Certified Systems Engineer
Certified Solaris Administrator
Red Hat Certified Engineer
[EMAIL PROTECTED]
fax 713-896-5266


>>> "Jennifer Pan" <[EMAIL PROTECTED]> 07/12/01 11:32AM >>>
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 

Reply via email to