> -----Original Message----- > From: eric-perl@pretorious.net [mailto:eric-perl@pretorious.net] > Sent: Wednesday, March 27, 2002 6:16 PM > To: Beginners Perl Mailing List > Subject: RE: Testing for filehandles > > > On Wed, 27 Mar 2002, Bob Showalter wrote: > > You can pass a filehandle glob to IO::Handle::opened(): > > Thanks, Bob! After reading the IO::Handle man page, I decided > to distill > this approach a bit further: > > print F if fileno(F); Of course, that's even simpler! Just to be nitpicky, the test maybe should be defined(fileno(F)) Since 0 is a valid file number (STDIN). If you're just going to do the test on the print statement, it's not accomplishing all that much, since the print() will silently fail if the file isn't open. But a test like this would be useful if you want to avoid doing a lengthy operation to generate the data to be printed.Thread Previous | Thread Next