0

Are there any grammar for indicating "Late Static Bindings" in perl?? In php, there is. http://php.net/manual/en/language.oop5.late-static-bindings.php

I'm just looking for them for perl.

cheek
  • 1

1 Answers1

5

Perl doesn't have static methods, so you don't need tricks to make static methods behave like virtual methods.

package ClassA {       
   sub who { print __PACKAGE__, "\n" }
   sub test { my ($class) = @_; $class->who(); }
}

package ClassB {
   our @ISA = 'ClassA';
   sub who { print __PACKAGE__, "\n" }
}

ClassA->test();  # ClassA
ClassB->test();  # ClassB
ikegami
  • 367,544
  • 15
  • 269
  • 518