my $file = shift; my $F = FileHandle->new; if( defined $F ) { $F->open($file) or die "can't open file $file: $!" } # it also lets you do things like $F->autoflush; # instead of that whole select() business