I have 2 questions.
1) Avoid warning message
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); }
gives me this error message: Name "main::LOG_FH" used only once: possible typo at...
Is the only way to get rid of the mssage to add
#no warnings 'once';
?
2) Create FILEHANDLE name from a variable
my $logfile = "test.log"; my $log_fh = "LOG_FH"; LOG_MSG_OPEN($log_fh,$logfile); ... sub LOG_MSG_OPEN { my $par_fh = $_[0]; my $par_filepath = $_[1]; my $par_fh_2 = *${par_fh}; open($par_fh_2,"> $par_filepath") or die ("Can't open $par_filepat +h: $!\n"); $par_fh_2->autoflush(1); }
gives me this error message: Can't use string ("LOG_FH") as a symbol ref while "strict refs" in use..
Is it possible to create FILEHANDLEs with a variable
Thanks for help.
Regards, de Michi
In reply to File Handle questions by demichi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |