Hi all, I'm trying to pass a filename into Log::Std, as is noted in the documenation for Log::StdLog:

use Log::StdLog { file => $filename };

Normally, Log::StdLog logs messages to a file named "$0.log" (that is, the current filename with .log appended. But if you pass a 'file' option, it uses that file as its logfile instead.

However, this only works if I specify the filename as $0.log and not $filename.

I found what I thought might have been the answer at the CPAN RT page for Log::Std, where someone posted a test script with the following code:

use Log::StdLog { file => "$0.log" }; # OK #use Log::StdLog { file => $filename }; # NOT OK
where the second option is commented out because it doesn't work (but it's what I want). Similarly, I tried using the following code suggested as a workaround on that same page:
use Log::StdLog; # at compile time my $file = "$config{dir}". basename($0) .".log.$$"; # at run time my $level = 'warn'; # specify file at runtime (below). Log::StdLog->import ({ level => $level, file => $file } ); # works, ru +ntime
Although this is what I want, it only works if you don't specify  use strict; use warnings;. And, of course, I have these in my code, and want to stick with them.

Doing a Supersearch and google turned up nothing that I haven't already seen. Anybody ran into this before or have any thoughts as to how I can pass in a filename?

-- Burvil


In reply to Passing filename to Log::Std by bowei_99

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.