You can find out the reason OUT is not opening as you expect by replacing
this:

open(OUT,">$outFile");

with this:

open(OUT,">$outFile") or die "Cannot open OUT: $!";

>-----Original Message-----
>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
>Sent: Tuesday, February 18, 2003 3:20 PM
>To: Perl-Unix-Users
>Subject: [Perl-unix-users] Problem writing to file
>
>
>Hi Gurus,
>    I am writing a small perl program which does some 
>processing on lots
>of files in a directory. But I get the following warning :
>"print() on closed filehandle OUT at
>home/parvez/MYWORK/PERL/PathFinders/StripText.pl line 29, <IN> line
>9431."
>
>my code is as follows:
><CODE>
>
>## Read the html dir
>$HTML_INDIR  = "/tmp/V2Files/";
>$HTML_OUTDIR = "/tmp/OutFiles/";
>
>my @files = glob($HTML_INDIR . "*");
>
>for(my $fileCnt = 0; $fileCnt <= $#files; $fileCnt++)
>{
>    print "processing file $files[$fileCnt] \n";
>
>    my $outFile = $HTML_OUTDIR . $files[$fileCnt];
>
>    open(IN, $files[$fileCnt]);
>    open(OUT,">$outFile");
>
>    while($line = <IN>)
>    {
>            print OUT $line;
>            ## LOTS OF OTHER PROCESSING HERE
>
>            next; ## debug purpose only
>    }
>    close IN;
>    close OUT;
>
>}
>
>exit;
>
>
>Please point out what is wrong in this code.
>
>Regards,
>Parvez
>
>_______________________________________________
>Perl-Unix-Users mailing list
>[EMAIL PROTECTED]
>To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>

_______________________________________________
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to