[ic] Adding a system wide module

Jon Jensen jon at endpoint.com
Mon Jan 31 20:45:25 EST 2005


On Tue, 1 Feb 2005, Jeff Fearn wrote:

>> The you can call it in a GlobalSub or UserTag, and perhaps even in a 
>> [perl global=1] block, provided that you have the catalog in the 
>> AllowGlobal configuration string.
>
> Does this mean that I need to write a wrapper for every function I
> wanted to use from Date::Calc?
>
> I was hoping to be able to bypass the Tag stuff entirely, just using
> [perl] and writting perl code in that on html pages.

If all you want is to pass through arguments to various subroutines in 
Date::Calc, you could create a global usertag wrapper like this:


     UserTag date-calc addAttr
     UserTag date-calc Routine <<EOR

     use Date::Calc;

     sub {
         my ($opt) = @_;
         my $out = eval "return Date::Calc::$opt->{op}(\@{\$opt->{args}})";
             if ($@) {
                     logError("tag date-calc error: $@");
                     return;
             }
             return $out;
     }
     EOR


You call the tag like this:

     [date-calc op=Day_of_Year args.0=2004 args.1=12 args.2=31]

I tested this code and it actually works. :)

Jon


-- 
Jon Jensen
End Point Corporation
http://www.endpoint.com/
Software development with Interchange, Perl, PostgreSQL, Apache, Linux, ...


More information about the interchange-users mailing list