in reply to Re: Inherit only few methods from a parent class
in thread Inherit only few methods from a parent class

Thanks much for everydody's reply. I impliment something like JavaFan recommends and it works..
Currently I am trying to avoid the following for like 90 methods..
sub risky_method1 {die "You're not allowed to call this"}
sub risky_method2 {die "You're not allowed to call this either"}

How can I impliment that? I heard about closures and AUTOLOAD in perl , Do you guys know which one is best?
Any examples

Thanks,
Shijumic
  • Comment on Re^2: Inherit only few methods from a parent class

Replies are listed 'Best First'.
Re^3: Inherit only few methods from a parent class
by Arunbear (Prior) on Jul 13, 2009 at 16:01 UTC
Re^3: Inherit only few methods from a parent class
by JavaFan (Canon) on Jul 13, 2009 at 15:47 UTC
    AUTOLOAD isn't going to work as AUTOLOAD will only be called if the method cannot be found.

    You could created the methods in a loop from a BEGIN statement. What I probably would do is write a one liner which generates the subs, which I'd then concatenate to the file.

      Would you please give me an example..
      Sorry I am new to Perl!!

      Thanks,
      Shijumic