Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Weird Exporter Problem in Mason with mod_perl2

by PetaMem (Priest)
on Oct 06, 2005 at 14:57 UTC ( [id://497949]=perlquestion: print w/replies, xml ) Need Help??

PetaMem has asked for the wisdom of the Perl Monks concerning the following question:

Hi, finally I set up a Apache2-2.0.54/mod_perl2-2.0.1/libapreq2-2.06-dev environment and am trying to ressurect a bigger Mason project (that worked with Apache2-2.0.48/mod_perl2-1.99xx/libapreq2 2.04-dev) It is executing components, but there is this problem.
<%once> use Module qw(somesub); </%once> ... ... ... <%init> ... &somesub(xxx); </%init>
Results in error:

Undefined subroutine &somesub called at ...

Why this? If I change "use Module" to "use sModule" he complains he cannot find it, so Module is really used. But then again if I enter total crap in "Module" which should provoke some syntax error - no one complains!?

Any hints?

Bye
 PetaMem
    All Perl:   MT, NLP, NLU

Replies are listed 'Best First'.
Re: Weird Exporter Problem in Mason with mod_perl2
by ikegami (Patriarch) on Oct 06, 2005 at 16:05 UTC
    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>
      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

Re: Weird Exporter Problem in Mason with mod_perl2
by pajout (Curate) on Oct 06, 2005 at 15:13 UTC
    I don't know mod_perl2 nor Mason, but, is'nt it possible that Module stays loaded, not reloaded after your code change? Can you stop and start Apache?
      restarting Apache fixed this for me.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://497949]
Approved by planetscape
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-04-24 06:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found