develooper Front page | perl.beginners | Postings from March 2002

RE: Testing for filehandles

Thread Previous | Thread Next
From:
eric-perl
Date:
March 27, 2002 13:44
Subject:
RE: Testing for filehandles
Message ID:
Pine.LNX.4.33.0203271236430.20427-100000@lucy
Tim:

I know, I know: I excluded the "or die" portion for 
readability/simplicity.

On Wed, 27 Mar 2002, Timothy Johnson wrote:
> You'd probably have better luck testing for the open() command's success

I wrote:
>> use Getopts::Std;
>> getopts("n");
>> open(OPT_LOG,">/tmp/foo.txt") if ($opt_n);
>> while (<>) {
>> 	print OPT_LOG $_ if OPT_LOG;
>> }
>> close(OPT_LOG) if OPT_LOG;

-- 
Eric P.
Los Gatos, CA


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About