[tpm] How to find my class name

Dave Doyle dave.s.doyle at gmail.com
Fri Mar 18 07:54:01 PDT 2011


__PACKAGE__->getter() should do the trick.  That way, if you change the
class name it's still good.
--
dave.s.doyle at gmail.com


On Fri, Mar 18, 2011 at 10:42 AM, Fulko Hew <fulko.hew at gmail.com> wrote:

> I have the following (simplified, and artificial) scenario:
>
> package testClass;
>
> my $classvar = 'data';
>
> sub getter {
>  my ($class, $mode) = @_;
>
>  $classvar = '' if ($mode eq 'reset');
>  return $classvar;
> }
>
> sub otherRoutine {
>  print "I got this from the reset getter: ", getter('reset'), "\n";
> }
>
> So in some cases code external to the class is
> going to want to call getter() this way:
>
> testClass->getter();
>
> but internally I also need to call him.
> I can't just call getter() because the $mode will not be the 2nd param
> because
> I didn't pass in the 'class'.
>
> What would be the right way of calling my own method?
> Ie. If 'SUPER' is the parent class, is there equivalent magic for
> 'THISCLASS'?
>
> Fulko
> _______________________________________________
> toronto-pm mailing list
> toronto-pm at pm.org
> http://mail.pm.org/mailman/listinfo/toronto-pm
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/toronto-pm/attachments/20110318/32a94f0d/attachment.html>


More information about the toronto-pm mailing list