sub open_logfile { my $filename = shift; open FH, '> ' . $filename or die "Can't write to $filename: $!\n"; select FH; }