Hello all,

I'm having trouble saving objects of my Registration class between pages on my web site. I'm saving the objects in an array using CGI::Session, like this:

# Add new registration object to the regArray my $ptrRegistrationArray = $session->param("registrationArray"); push(@$ptrRegistrationArray, $ptrCurrentRegistration); $session->param("registrationArray", $ptrRegistrationArray); $session->flush();

I call the sequence above on two different pages (representing two paths available for the user: create new registration or renew an existing registration). The following page is a review screen where the paths converge; it pulls all registration info out of the registrationArray for display, like this:

my $ptrRegistrationArray = $session->param("registrationArray"); foreach my $reg (@$ptrRegistrationArray) { print STDERR "reg is a " . ref($reg) . "\n"; print STDERR "reg = " . Dumper($reg) . "\n"; print STDERR "reg->can('testMethod') results: " . $reg->can("testMethod") . "\n"; # testMethod() is basically a "hello world" for the # Registration class. $reg->testMethod(); # Other work here }

The puzzling/perplexing/frustrating as hell bit: the review page works for the 'renew' path, but fails for the 'new' path (for clarity: 'new' here is referring to a new user registration, not Registration::new()). Here's the output for the renew path (working example):

reg is a Registration reg = $VAR1 = bless( { 'name1' => 'value1', 'name2' => 'value2', 'name3' => 'value3', }, 'Registration' ); reg->can('testMethod') results: CODE(0x83406b8) hello world

And here's the output for the new path (failing example):

reg is a Registration reg = $VAR1 = bless( { 'name1' => 'value1', 'name2' => 'value2', 'name3' => 'value3', }, 'Registration' ); reg->can('testMethod') results: <conspicuously blank!> Can't locate object method "testMethod" via package "Registration"

As you can see, although the instance's data makes it out of the extraction process on the 'bad' path just fine, the class seems to have forgotten it's methods; almost like it's reverted to a simple hash. However, calling ref($object) - not to mention the Data::Dumper output - indicate this object is recognized as a Registration class instance. It's "bless"ed & everything! Although clearly not by the right gods...

I'm about out of hair to pull (didn't have much to start with). Anyone have any idea what could be happening to my objects here?


In reply to "Can't locate object method"...? Why not??? by Anonymous Monk

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.