use strict; use warnings; my $logfile = "test.log"; my $log_fh = *LOG_FH; LOG_MSG_OPEN($log_fh,$logfile); ... sub LOG_MSG_OPEN { my $par_fh = $_[0]; open($par_fh,"> $par_filepath") or die ("Can't open $par_filepath: $!\n"); $par_fh->autoflush(1); }