in reply to Re: Don't know how to make a module for this repeating code
in thread Don't know how to make a module for this repeating code

Thanks for answering, and helped me to think deeper for what is my question...

So, I think my problem is not worrying how to create this package. Perhaps I can make a module to auto update the interface version triggered by the implementation classes as well.

But then, seems what really interested me is how to eliminate this kind of "code", when this code is a constructor. like.. can I eval() some text which return from a package that carrying the script body etc..

  • Comment on Re^2: Don't know how to make a module for this repeating code

Replies are listed 'Best First'.
Re^3: Don't know how to make a module for this repeating code
by Anonymous Monk on Nov 25, 2012 at 10:21 UTC

    can I eval() some text which return from a package that carrying the script body etc..

    What does that mean?

      umm... perhaps I can create something like this:
      package ExtConstructor; sub new { return <<" CODE"; eval 'use parent "parent::classes"'; sub new { return bless $_[0]->SUPER::new(); } CODE } 1; package Interface::Module; use ExtConstructor; my $code = new ExtConstructor; eval $code; # so that the constructor code created on-the-fly 1; package main; use Interface::Module; my $obj = new Interface::Module;