Menu

main::FATAL redefined error

Help
rschramm
2006-11-03
2013-06-04
  • rschramm

    rschramm - 2006-11-03

    Somewhat a newbie to perl...
    I seem to be bumping into compatibility between Log4Perl and NetCDF
    packages. The program below prints the following whenever I run it.
    1)If I comment out the use NetCDF it goes away...
    2)If I switch order of the 'use' so that netcdf comes first, no error...

    Log4perl seems to work ok for this simple app even with the warning. I havent exercised the NetCDF package yet... Should I be worried?

    Thanks for any help. -Rich

    Subroutine main::FATAL redefined at /usr/lib/perl5/5.8.0/Exporter.pm line 60.

    #!/usr/bin/perl -w
    use Log::Log4perl qw(:easy);
    use NetCDF;
    Log::Log4perl->easy_init($WARN);
    my $logger = get_logger();
    $logger->debug("debug message ");
    $logger->info("info message ");
    $logger->warn("warn message ");
    $logger->error("error message ");
    $logger->fatal("fatal message ");

    #### sample outpit below this line ####

    >test.pl
    Subroutine main::FATAL redefined at /usr/lib/perl5/5.8.0/Exporter.pm line 60.
    at test.pl line 3
    2006/11/02 16:03:20 warn message
    2006/11/02 16:03:20 error message
    2006/11/02 16:03:20 fatal message

     
    • Mike Schilli

      Mike Schilli - 2006-11-04

      NetCDF exports a whole slew of symbols into the importing script's namespace by default, among them a function called FATAL.

      Log::Log4perl, when imported with the :easy tag, will also import a function named FATAL into the caller's namespace. Since you're not using Log4perl's convenience functions like DEBUG(), ERROR(), FATAL() etc. but their logger methods debug(), error(), fatal(), you could work around the issue by importing Log4perl via

          use Log::Log4perl qw(:levels);

      which will get you levels like $DEBUG etc. but not the convenience functions.

      Oh, and a note to NetCDF's author would be in order. Polluting a caller's namespace by default is bad style.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.