in reply to use module question.
This way, anytime you have a new specie to handle you just have to write a new module, without modifying your using code.my $spec = .... ; # H, M , etc... my $mod = "mod".$spec ; # Modules named modH , modM , etc.. eval "require $mod;"; if( $@ ){ die "Cannot load module $mod for specie $spec : $@"; } #Then, use your module function f1 , f2.. by: $mod->f1() or $mod::f2() etc...
In general, avoid to construct case like structure. It makes your code hard to maintain and is a bit outdated.
Dynamicity of perl is easy to write and very rewarding to use. Use it !! J.
|
|---|