[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [ic] Calling subs from usertags


Daniel Browning suppressed wrote:
> What is the best method to call subs from usertags?  Here is what I've
> been using: 
> 
> For globalsubs from global usertags:
> 
> $Global::GlobalSub->{ name_of_sub }->( 'arg1', 'arg2' );
> 
> For catalog subs from catalog usertags:
> 
> $Config->{Sub}{ name_of_sub }->( 'arg1', 'arg2' );
>
Those look correct to me.  You'll need to test the Sub before you
use it, as follows:

    my $sub = $Config->{sub}->{name_of_sub};
    $sub->('arg1','arg2') if ref($sub) eq 'CODE';

There's also $Vend::Cfg->{Sub}->{subname} which, if memory serves,
is the same as $Config->{Sub}->{subname}, but for use in a global
UserTag.

In a global UserTag, you could allow a local Sub to override a GlobalSub
as follows:

    my $sub = $Vend::Cfg->{Sub}->{subname} || $Global::GlobalSub->{subname};
    $sub->('arg1','arg2') if ref($sub) eq 'CODE';

-- 
   _/   _/  _/_/_/_/  _/    _/  _/_/_/  _/    _/
  _/_/_/   _/_/      _/    _/    _/    _/_/  _/   K e v i n   W a l s h
 _/ _/    _/          _/ _/     _/    _/  _/_/    suppressed
_/   _/  _/_/_/_/      _/    _/_/_/  _/    _/

_______________________________________________
interchange-users mailing list
suppressed
http://www.icdevgroup.org/mailman/listinfo/interchange-users


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.