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...