use Local::Some::Real::Cool::Module; $this = Local::Some::Real::Cool::Module->new(); $that = Local::Some::Real::Cool::Module->new(); $more = Local::Some::Real::Cool::Module->new();
Sometime ago I learned I could set a string to the module name and use it instead:
use Local::Some::Real::Cool::Module; $gimme = 'Local::Some::Real::Cool::Module'; $this = $gimme->new(); $that = $gimme->new(); $more = $gimme->new();
That is better, but still kinda sucks. So I try to have the module return its own name and get it that way, but of course the return of use can't be used:
# Nope $gimme = use Local::Some::Real::Cool::Module;
Maybe the return of require can be used to grab the module name? Yes it can. But will I be sorry if I do? Any other suggestions?
#!/usr/bin/perl my $gimme = require Local::Some::Real::Cool::Module; import $gimme qw(some import stuff here); my $this = $gimme->new(); my $that = $gimme->new(); my $more = $gimme->new(); #----------------------------------------------------------- # Local/Some/Real/Cool/Module.pm #----------------------------------------------------------- package Local::Some::Real::Cool::Module; sub import { # . . . } sub new { return bless {}, shift; } 'Local::Some::Real::Cool::Module';
YuckUse
In reply to use, require, and constructors by YuckFoo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |