in reply to Re: Re: Re: use/require $MODULE (a variable)
in thread use/require $MODULE (a variable)
Ah, I see, well, there are a few tricks you can do for plain .pl files... you could do (sort of) what Exporter is doing, which is symbol table munging, or you could cheat a little and do something like
## beware! very much untested, it's incomplete, ## and it needs lots of error checking. use IO::File; sub import { ## if the module is a plain .pl file... my $fh = IO::File->new( $module ); local $/ = undef; my $text = <$fh>; undef $fh; my $caller_pkg = ((caller())[0] eval "package $caller_pkg; $text"; }
Obviously, this is a hack and it won't always work (furthermore, it's ugly). But at least you could *attempt* to load them files to the correct namespace. ;)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Re: use/require $MODULE (a variable)
by cadphile (Beadle) on Mar 18, 2002 at 09:08 UTC |