in reply to Re: File Handle questions
in thread File Handle questions

Hi,

this

my $log_fh = \*LOG_FH;

does not help as I get the same errors. But returning the FH in the sub works :)

my $log_fh; # = \*LOG_FH; $log_fh = LOG_MSG_OPEN($log_fh,$logfile); LOG_MSG($log_fh,$vbse,"v",$lglvl,5,"GENERAL","Starting Script $0"); ... module ... sub LOG_MSG_OPEN { my $par_fh = $_[0]; my $par_filepath = $_[1]; open($par_fh,"> $par_filepath") or die ("Can't open $par_filepath: + $!\n"); $par_fh->autoflush(1); return *$par_fh; } sub LOG_MSG { my $par_fh = shift (@_); ... print $par_fh "$logdate,$logtime,$SEV_KEYWORD,$par_FUNCTION,@line\ +n"; }

Thanks for your other recommendations. I always used uppercase fos my subs. I will check the open and autodie. Kind regards, de Michi

Replies are listed 'Best First'.
Re^3: File Handle questions
by kcott (Archbishop) on Oct 27, 2016 at 13:20 UTC
    "... my $log_fh = \*LOG_FH; does not help as I get the same errors."

    I suggested declaring LOG_FH to "fix both your posted problems".

    Using the globref, \*LOG_FH, was to handle an anticipated, subsequent problem.

    — Ken