in reply to Lost methods

perl -V says:

Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration:
Platform: osname=solaris, osvers=2.8, archname=sun4-solaris

I think 5.6.1. is OK?

The code is a small component in my HTML:Mason site. Basically, it's a Perl subroutine embedded in an html page. Mason components run in the HTML::Mason::Commands namespace. This component should just spit out the user's name. Errors are caught by Mason and formatted as html, hence the <br />'s:

use MyApp::Person; my $user = $session->param('user'); # CGI::Session my $name; eval{$name = $user->full_name} if $user; if ($@) { my $dump_user = Data::Dumper->Dump([$user], ['$user']); $dump_user =~ s|,|,<br />|g; my $package = __PACKAGE__; my @methods = qw( ... all the methods from MyApp::Person ... ); my $check_methods; foreach my $method (@methods) { $check_methods .= sprintf "%s %s <br />", $user->can($method) +? 'CAN' : 'CANNOT', $method; } my $dummy = $MyApp::Person::dummy_true ? $MyApp::Person::dummy_tru +e : 'FALSE'; my $loaded_modules; foreach my $mod (sort values %INC) { $loaded_modules .= "$mod<br />"; } my $ref_user = ref($user); die "Current package: $package<br /> Dummy variable: $dummy<br /> \$user is a $ref_user<br /> $check_methods<br /> \@INC:<br /> $loaded_modules<br /> $dump_user<br />"; } else { [... do something with $name ...] }

The MyAPP was a typo ...

All the things in the die statement check out - except all the methods come out CANNOT:

Current package: HTML::Mason::Commands Dummy variable: 1 $user is a Icapb::Person CANNOT new CANNOT _init CANNOT _check_user_type CANNOT _load_cv CANNOT ... etc etc etc @INC: ... /home/dave05/lib/perl5/mylib/MyApp/Person.pm ...

and $user is initialised with all the appropriate data.

I like Chmrr's suggestion. I develop in Win32, and run this thing on solaris, so maybe a bad line/file ending got in there somewhere, I'll check that out.

I'm not sure how use base can help me? My Person object isn't derived from anything else.

Thanks all, progress report soon!

Replies are listed 'Best First'.
Re: Lost methods
by Abigail-II (Bishop) on Nov 26, 2002 at 15:37 UTC
    Well, according to your own code, $user is an instance of the Icapb::Person class. So, unless Icapb::Person inherits MyApp::Person, I'm not at all surprised you can't call those methods.

    Abigail

      Sorry, that's another typo, I've been changing the names to protect the innocent, and that slipped through.