Hello, Monks! I'm humbly seeking some guidance in order to find some peace...

I'm developing my own nuts-n-bolts CMS-like software for a few intranet applications. The issue I'm encountering is that when I try to use a module I've written via one of my Mason pages I'm getting a "Can't locate object method 'foo' via package 'bar'..."

This works just fine, mind you in external scripts. I can guess it's something with the way I'm blessing the reference? I don't know. My 'new' sub works and it returns a reference.

However...If I call another routine in the module I get the error mentioned above. Where oh where am I going wrong? Here's the Mason code (I'm declaring the database handle as a global in the autohandler):

... <%once> use lib '/var/www/nlt/libs'; use CMS::Users; my $u = CMS::Users->new(); $u->SetDBH($mysql_db_handle); print $u->GetUserList(); </%once> ...
There is litterally nothing else in this file but a paragraph tag at the bottom with the word "testing" in it.

Here's some code I threw together to troubleshoot the problem:

package CMS::Users; use Digest::MD5 qw(md5); use CGI; sub new { my $class = shift; my $self = { }; bless $self, $class; return $self; } sub SetDBH { my ($self, $dbh) = @_; if ($dbh) { $self->{DBH} = $dbh; return 1; } else { return undef; } } sub GetUserList { my ($self,%args) = @_; return "Sub call worked. I'm from: $self"; } 1;
Strangely enough the SetDBH routine works without incident. While GetUserList produces the error. What gives? I'm losing my mind and can't seem to figure out why it's not working. Thank you all in advance for reading through this (if you are still reading).

--dom

In reply to My module's methods aren't working under Mason pages? by domje

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.