You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Stas Bekman <st...@stason.org> on 2001/03/09 18:06:13 UTC

Re: Read on closed file handle?

On Fri, 9 Mar 2001, David Jourard wrote:

> Hi,
>
> In my startup.pl I'm calling a function that initializes read-only
> variables - read in from several text files.
>
> After it reads in the first it fails on every one thereafter with the message:
>
> Read on closed filehandle <SYS1> at lpinit.pl line 78
> Read on closed filehandle <SYS2> at lpinit.pl line 99
>
> etc..
>
> Here some sample code in lpinit.pl

[snip]

>    open(SYS2, "$PathData/file2.txt");
>    while (<SYS2>) {
>      	# Read in the data from file2
>
>       }
>    }
>    close SYS2;
>
> It works for the first but fails for the 2, 3, 4, 5 and 6th.
>
> Any ideas whats causing the error.

Sure, have you ever thought of checking the return code of the open()
function?

 open FOO, $foo or die "Here comes the error: $!";

_____________________________________________________________________
Stas Bekman              JAm_pH     --   Just Another mod_perl Hacker
http://stason.org/       mod_perl Guide  http://perl.apache.org/guide
mailto:stas@stason.org   http://apachetoday.com http://logilune.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/