Simply changing our to my will avoid the package variable if that's what you meant by global. There's nothing wrong with this particular var being global (whether my or our).

You're using indirect object notation (method Class @args) which is iffy. Class->method(@args) is more reliable, better recognized and more readable.

You don't need new_from_fd at all unless you plan on passing the handle to child processes.

Don't need to include the line number in a message destined to the user.

use IO::Handle qw( ); my $LOGFH; if ( $opt_s ) { $LOGFH = \*STDOUT; } else { $opt_l = $DEFAULT_LOG_FILE if !defined($opt_l); open( $LOGFH, '>>', $opt_l ) or die("Could not open logfile \" $opt_l\": $!\n"); } $LOGFH->autoflush(1); #autoflush on

In reply to Re: Best method for opening/using a log by ikegami
in thread Best method for opening/using a log by automandc

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.