in reply to Weird Exporter Problem in Mason with mod_perl2

use Module qw(somesub);
is equivalent to
BEGIN { require Module; Module->import('somesub') if Module->can('import'); }

You've prooved that require Module; works, and there's no reason to believe if Module->can('import') fails, so we're left with Module->import('somesub'). My bet is that importing works, but it's importing to the wrong namespace. Look into which namespace is used for once vs init. If the following work, my hypothesis is confirmed:

<%once> # warn("once: " . __PACKAGE__ . "\n"); require Module; # or: use Module (); # but not: use Module; # An empty list disables import, # but ommiting the list does not. </%once> ... ... ... <%init> # warn("init: " . __PACKAGE__ . "\n"); Module->import(qw(somesub)); ... &somesub(xxx); </%init>

Replies are listed 'Best First'.
Re^2: Weird Exporter Problem in Mason with mod_perl2
by PetaMem (Priest) on Oct 06, 2005 at 20:55 UTC
    My bet is that importing works, but it's importing to the wrong namespace. Look into which namespace is used for once vs init. If the following work, my hypothesis is confirmed:

    Unfortunately - doesn't work.

    Namespace in <%once> is "HTML::Mason::Commands" too.

    The warn in <%init> is not even executed, the error seems to come during compile time?

    Bye
     PetaMem
        All Perl:   MT, NLP, NLU