On Thu, 18 May 2000, Vivek Khera wrote:

> >>>>> "DM" == Doug MacEachern <[EMAIL PROTECTED]> writes:
> 
> DM> On Wed, 17 May 2000, Matt Sergeant wrote:
> >> Well, this may be true, but if you load IO::File before startup then it's
> >> not too big a deal...
> 
> DM> but it still adds a great deal of bloat to the server.  and it's oo
> DM> interface, while very slick, adds quite a bit of runtime overhead, turn
> DM> the sugar sour imo.
> 
> In an embedded environment like mod_perl, then how do you suggest to
> deal with the dangling file handles problem?  That is, I'm processing
> a file or two, and some error occurs.  In a normal perl program, I'd
> exit or return out and then when the program terminates, it
> automagically closes all the files.  In mod_perl, the auto-close
> doesn't happen until much later.  With the OO interface, when the
> handle goes out of scope, such as a function call return, the file is
> implicitly closed.
> 
> What other mechanism do you propose to handle this situation other
> than IO::File?  I use it all the time myself.

use Apache;
use Fcntl qw/:DEFAULT :flock/;
my $fh = Apache->gensym();
sysopen($fh, "file", O_RDONLY) || die "Can't open: $!";
flock($fh, LOCK_SH) || die "Can't lock: $!";
...

when $fh goes out of scope it's closed and unlocked.

Also see the guide section on exception handling.

-- 
<Matt/>

Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org http://xml.sergeant.org

Reply via email to