From: Graham B. <gb...@po...> - 2000-05-26 19:11:22
|
On Fri, May 26, 2000 at 01:30:00PM -0500, Mark Wilcox wrote: > Hi, > I really like the idea of using IO::File for the filehandle passed to > Net::LDAP::DSML. However, what I need to know is should that file handle > already be open? Or should we open it? > > What about closing it? > > I'm leaning more towards assuming it's open and let the user open & > close. I'd hate to close a socket or pipe on someone. Allow the user to pass either an open handle or a file name. Don't force an IO::* anything either. ie my $file = shift; my $fh; my $close; if (ref($file) or ref(\$file) eq "GLOB") { $close = 0; $fh = $file; } else { local *FH; open(FH,"$file); $close = 1; $fh = \*FH; } ... close($fh) if $close; Graham. |