[ic] delimiter for tag parameters

Peter peter at pajamian.dhs.org
Thu Oct 27 08:58:35 EDT 2005

On 10/26/2005 11:12 PM, Kevin Walsh wrote:
>     UserTag mytag Order title description
>     UserTag mytag Routine <<EOR
>     sub {
>         my ($title,$description) = @_;
>         ...
>     }
>     EOR

Or (untested, but should work) ...

UserTag mytag Routine <<EOR
sub {
	my ($opt) = @_;
	my ($title,$description) = @{$Scratch}{@{$opt}{'title','description'}};

Which, to explain the above, dereferences $opt into a hash, then 
produces an array slice from the hash elements corresponding to the 
title and description keys, then dereferences $Scratch into a hash and 
produces an array slice from it using the above array as the keys.

Note that this will fail miserably if you fail to pass either title or 
description attributes to the tag, or if they don't match a 
corresponding scratch variable.

To be honest (and for my 2 cents) I tend to like Kevin's workaround of 
using [mytag title="[scratch title]"] the best for the following reasons...

1) You can use that workaround on other existing tags without having to 
modify the tag itself.

2) You can still call your own tag with [mytag title="My title"] from 
other places without having to set the title in a scratch.

3) It's really not that much less efficient than the other methods 
mentioned to be worth it (imo).  To me, the most inefficient operations 
are database and file accesses and that workaround doesn't require any 
more of either one.


More information about the interchange-users mailing list