http://www.perlmonks.org?node_id=938334


in reply to Can't call method on an undefined value

Check when the method is called. It might happen that you call it before the variable "$logger" is created in main. For example this might happen if you call it directly in the body of the module you "use". Here's example.

package MyModule; $main::logger->debug("This may fail"); sub func { $main::logger->debug("This is OK"); } 1;