G'day demichi,
Declaring LOG_FH should, I think, fix both your posted problems.
You'll then find another problem with your $log_fh assignment.
You need to assign a globref:
#my $log_fh = *LOG_FH;
my $log_fh = \*LOG_FH;
To be honest, I don't know why you're even bothering with that globally-scoped package variable.
Why not just:
my $log_fh;
LOG_MSG_OPEN($log_fh,$logfile);
Recomendations:
-
Names with all uppercase characters are typically reserved for constants, filehandles, and so on.
Using them for other purposes (e.g. LOG_MSG_OPEN in your post) can be confusing and error-prone.
-
Use the 3-argument form of open.
-
Consider using the autodie pragma.
Update:
Expanded the "Names with all uppercase characters ..." point.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.