Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

cgi and inheritance

1 view
Skip to first unread message

Patton, Billy

unread,
Oct 6, 2014, 9:33:12 AM10/6/14
to beginn...@perl.org
I’ve recently inherited some code that hasn’t been touched in over 5 years. It’s all cgi and OOPerl.
I’ve ran across this one statement that I don’t understand.

$self->log->error(*)

I know the self
and I’ve traced the error to CGI::Application through inheritance.
But it’s the ->log-> that has me confused.
I have no class named log
I find no place that is does a new on log anywhere in the family tree.
I cannot find any log class anywhere in the family tree of inheritance.

Is this just a method of using a perl hash that I’m not familiar with?
Could it be rewritten as
$self->{‘log’}->error(*);

Using perl 5.16.2
on MAC 10.9.5

John SJ Anderson

unread,
Oct 6, 2014, 9:41:33 AM10/6/14
to beginn...@perl.org
On Mon, Oct 6, 2014 at 6:33 AM, Patton, Billy <Billy....@h3net.com> wrote:
> I’ve recently inherited some code that hasn’t been touched in over 5 years. It’s all cgi and OOPerl.
> I’ve ran across this one statement that I don’t understand.
>
> $self->log->error(*)

That's calling the 'error()' method, on the result returned by calling
the 'log()' method, on the current object ($self).

You could also write that as:

my $log = $self->log();
$log->error(*)

(I'm assuming '*' is a stand-in for the actual arguments.)

chrs,
john.

jbde...@earthlink.net

unread,
Oct 8, 2014, 2:29:53 AM10/8/14
to Patton,Billy, beginn...@perl.org
I haven't seen any PErl code with ->log-> like that before. I've only seen code like that with = error(*).

-----Original Message-----
>From: "Patton, Billy" <Billy....@h3net.com>
>Sent: Oct 6, 2014 9:33 AM
>To: "beginn...@perl.org" <beginn...@perl.org>
>Subject: cgi and inheritance
>
>I’ve recently inherited some code that hasn’t been touched in over 5 years. It’s all cgi and OOPerl.
>I’ve ran across this one statement that I don’t understand.
>
>$self->log->error(*)
>
>I know the self
>and I’ve traced the error to CGI::Application through inheritance.
>But it’s the ->log-> that has me confused.
>I have no class named log
>I find no place that is does a new on log anywhere in the family tree.
>I cannot find any log class anywhere in the family tree of inheritance.
>
>Is this just a method of using a perl hash that I’m not familiar with?
>Could it be rewritten as
>$self->{‘log’}->error(*);
>
>Using perl 5.16.2
>on MAC 10.9.5
>--
>To unsubscribe, e-mail: beginners-cg...@perl.org
>For additional commands, e-mail: beginners...@perl.org
>http://learn.perl.org/
>
>

0 new messages