in reply to setting 'no strict refs' in a module from the script
You can always replace &strict::import. Something like this untested piece of code may do:
package StrictDisallow; no warnings; BEGIN { require strict; *o_import = \&strict::import; *strict::import += \&n_import } our %disallow; our @stricts = qw(refs subs vars); sub import { shift; my $namespace = shift; return unless $namespace && @_; %disallow = (%disallow,$namespace,[@_]); } sub n_import { my $caller = caller; if (exists $disallow{$caller}) { my $class = shift; my %temp; if (@_ == 1) { @temp{@stricts} = (); } else { @temp{@_} = (); } delete @temp{@{$disallow{$caller}}}; return unless %temp; @_ = ($class,keys %temp_hash); } &o_import; } 1;
Then you'd use it like:
#!/usr/bin/perl -w use strict; use StrictDisallow Term::Cap => "refs"; ...
Just be certain to use StrictDisallow before loading the modules you wish to restrict.
I hope this helps.
antirice
The first rule of Perl club is - use Perl
The ith rule of Perl club is - follow rule i - 1 for i > 1
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: setting 'no strict refs' in a module from the script
by zentara (Cardinal) on Jan 26, 2004 at 20:12 UTC | |
by antirice (Priest) on Jan 26, 2004 at 21:02 UTC |