exilepanda has asked for the wisdom of the Perl Monks concerning the following question:
Hi monks,
I have a module that acting as an interface which looks quite similar to this :
I've repeating (copy and paste) this code(file) in every module that has similar purpose. But since this is repeating code, so I am wondering is there anyway I can snap out this code into some central place... The only different things among these interface modules is only the had coded part. But then...I have no idea how to offshore a constructor... can anyone tell me an idea for how to get a start ?package Some::Interface; use strict; my $formType = "HR-Recruitment"; # hard coded my $lastVerion = "hr_re_v12"; # hard coded eval "use parent 'somepack::$formType::$lastVersion';"; sub new { my $c = shift; # some statements to check if any error in @_ # some statements to check access right my $wrap = $c->SUPER::new( @_ ); # some statements to add more attributes for $wrap return bless $wrap; } 1;
*UPDATE: my ultimate wish is I can make it as few lines as possible when I am creating another interface module.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Don't know how to make a module for this repeating code
by zwon (Abbot) on Nov 24, 2012 at 16:24 UTC | |
by exilepanda (Friar) on Nov 24, 2012 at 17:06 UTC | |
by Anonymous Monk on Nov 25, 2012 at 10:21 UTC | |
by exilepanda (Friar) on Nov 27, 2012 at 05:24 UTC |
Back to
Seekers of Perl Wisdom