CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: [ohaya] Another Log::Message problem - Can't call method "croak" on an undefined value: Edit Log



Zhris
Enthusiast

Apr 11, 2018, 5:44 PM


Views: 2546
Re: [ohaya] Another Log::Message problem - Can't call method "croak" on an undefined value


Quote
Also, I have an off-topic question: Why are there two config files that are needed? I set them both to the same file for now but I don't understand why it would need to different configuration files?


Providing config attributes on use sets the default attributes on new. This is useful if you are creating more than one Log::Message object which share some of the same attributes, but not others. I personally don't like the use / import interface, and would just provide all of the attributes on new. it provides clarity and doesn't cause issues later if multiple instances across multiple scripts ( default config is stored in a global package variable! ).


Code
use Log::Message level => 'log'; 
my $one = Log::Message->new( config => 'one' );
my $two = Log::Message->new( config => 'two' );

# is equal to:

use Log::Message;
my $one = Log::Message->new( level => 'log', config => 'one' );
my $two = Log::Message->new( level => 'log', config => 'two' );


Chris


(This post was edited by Zhris on Apr 11, 2018, 5:52 PM)


Edit Log:
Post edited by Zhris (Enthusiast) on Apr 11, 2018, 5:47 PM
Post edited by Zhris (Enthusiast) on Apr 11, 2018, 5:49 PM
Post edited by Zhris (Enthusiast) on Apr 11, 2018, 5:50 PM
Post edited by Zhris (Enthusiast) on Apr 11, 2018, 5:51 PM
Post edited by Zhris (Enthusiast) on Apr 11, 2018, 5:51 PM
Post edited by Zhris (Enthusiast) on Apr 11, 2018, 5:52 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives