[ic] Setting multiple scratch in one tag

Davor Ocelic docelic at mail.inet.hr
Sat Jun 24 14:24:32 EDT 2006


On Sat, 24 Jun 2006 10:08:07 -0700
"Paul Jordan" <paul at gishnetwork.com> wrote:

> I was
> wondering, would there be any efficiency gain to have a tag made that did
> something like the following:
> 
> [tmp list=1]
> 	page_title: Home
> 	seetab: home
> 	subtab_a: 1
> 	foo: [sql-param bar]
> [/tmp] 
> 
> I imagine that it only needs to call ?something? once to set all four, yes?
> I am mainly thinking of the typing speed, readability and maintenance of
> these things, as well as any execution gains.

Hey Paul,

why not something like:

[calc]
	my %set = (
		key1 => 'val1',
		key2 => 'val2',
		key3 => 'val3',
	);

	while (my ($k,$v) = each %set) { $Tag->tmp($k, $v) }
[/calc]


Too bad this can't be shorten even further. The 'each' iterator
only accepts an already existing hash (can't use (k1=>v1) or %{ k1=>v1 }
in place of %set), and it's also not possible to use the shorter form
in 'while' (   $Tag->tmp($k, $v) while (my ($k,$v) = each %set)   ).



More information about the interchange-users mailing list