http://www.perlmonks.org?node_id=999333

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

package p4_cache::p4; use strict; use warnings; use base qw(P4); use Params::Validate qw( validate_with SCALAR OBJECT BOOLEAN UNDEF ARR +AYREF HASHREF); use Data::Dumper; use Class::MethodMaker [ new => [ '-hash', '-init', 'new'], scalar => 'clientname' ]; sub init { my $self = shift; my %opts = validate_with( params => \@_, spec => { 'clientname' => { type => SCALAR }, 'port' => { type => SCALAR, optional => 1 } }, ); my $port = $opts{'port'}; if (!defined($port)) { my @p4_client = split /:/, $opts{'clientname'}; $port = "p4mynet-p4p-".lc($p4_client[1]).":188"; } # Connect to p4 $self->SUPER::new(); print Dumper($self); $self->SetClient($opts{'clientname'}); $self->SetPort($port); $self->Connect() || die 'Unable to connect to p4 server'; return $self; } ## end of sub init When I am trying to execute this code through my.pl Call present in pl my $obj = p4_cache::p4->new(clientname => 'keys:SITE:dev2'); I am getting a following error : $VAR1 = bless( { 'clientname' => 'keys:SITE:dev2' }, 'p4_cache::p4' ); No '_p4client_ptr' member found in P4 object! at p4_cache/p4.pm line 3 +2. No '_p4client_ptr' member found in P4 object! at p4_cache/p4.pm line 3 +3. No '_p4client_ptr' member found in P4 object! at p4_cache/p4.pm line 3 +4. Unable to connect to p4 server at p4_cache/p4.pm line 34. No '_p4client_ptr' member found in P4 object!. Looking forward for some help on this. Thanks in advance.

Replies are listed 'Best First'.
Re: No '_p4client_ptr' member found in P4 object
by Tanktalus (Canon) on Oct 16, 2012 at 23:02 UTC

    Where does this error message come from? It doesn't look like an error message from perl, so I'm guessing it's a message coming from P4, the base class. Have you looked at that code to see why it's throwing an error?

    By the way, $self->SUPER::new() isn't going to do what you think it is. I'm not sure what the right answer is, but if you're using the same design point as in P4, then you might mean $self->SUPER::init(@_); instead. Again, I'd have to see P4 ... and I'd also have to learn Class::MethodMaker.