[tpm] How to find my class name

Fulko Hew fulko.hew at gmail.com
Fri Mar 18 07:42:27 PDT 2011

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:


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'?


More information about the toronto-pm mailing list