[ic] Adding a system wide module

Jeff Fearn jefffearn at gmail.com
Wed Feb 2 00:22:00 EST 2005


On Tue, 1 Feb 2005 09:27:36 -0500, Mike Heins <mike at perusion.com> wrote:
>
> Perhaps you can develop the Safe stuff so that it makes it easier. 8-)

I have had a look and came up with a possible solution.

I modified Interpolate.pm by adding a hash that contains a module name
as a key and an array of functions as the value, this is set in the
BEGIN.

        %Share_from = ( "Date::Calc" => ['Decode_Date_EU', 'Today']);

Then in reset_calc, just below
"$ready_safe->untrap(@{$Global::SafeUntrap});" I added this:

                foreach my $key (keys(%Share_from))
                {
                        $ready_safe->share_from($key, $Share_from{$key});
                }

This allows Decode_Date_EU and Today to be used as if you used use
Date::Calc qw(Decode_Date_EU, Today) within a Tag or [perl] block.

share_from moves the function into the Safe name space, it stills runs
these functions within the Safe.

Presumably $Share_from could be initialised in another place, like a
cfg file, if required.

I think this is a fairly safe way to do this, any thoughts?

Jeff


More information about the interchange-users mailing list