OK, I'm on day 3 of trying to track down this one, so I'm turning to the Monks for some pointers.

This thing is a web site, running under HTML::Mason. I have a MyApp::Person object representing a logged in user. I can happily use the object to run through all the registered users in my database, and call methods to print out a list of names for instance.

But when I have a specific user logged in, and identified via a cookie, I get this error when trying to call methods off the user stored in the cookie (the cookie stores an ID string, which identifies a file on the server that holds the user data which is used to initialise the $user object):

Can't locate object method "full_name" via package "MyApp::Person" (perhaps you forgot to load "MyApp::Person"?)

Here's the thing. If I check %INC, MyAPP::Person _is_ loaded.
Also: ref($user) returns MyApp::Person
The next thing: if I run a $user->can('full_name'), it can't.
Next: in fact, my $user can't do _any_ of the MyApp::Person methods.
BUT: if I stick a dummy variable in MyApp/Person.pm (our $dummy_true = 1;), then I _can_ successfully read the dummy variable (via $MyApp::Person::dummy_true).

So basically, I can access the MyApp::Person namespace, but I can't use $user to get hold of any methods defined in there, despite ref($user) == MyApp::Person

One specific question I'd like to ask is: how can I check the package my code is currently running under?

But what I'd really like is suggestions as to where to look next.

D.


In reply to Lost methods by Dave05

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.