[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date
][Minivend by thread
]
use of safe_tag() in perl (fwd)
****** message to minivend-users from Kyle Hayes <kyle540@quicknet.net> ******
Hi all,
I have been trying to use the safe_tag() in perl. It does not react as I
expected and I am wondering what I am doing wrong.
I have a UserTag defined like this:
UserTag test-tag HasEndTag 1
UserTag test-tag Interpolate 1
UserTag test-tag Order arg1 arg2 arg3
UserTag test-tag Routine <<EOR
sub {
my $a;
my $out;
for $a (@_)
{
if( defined($a) ) {
$out .= "Arg Value is: $a\n";
}
}
return $out;
}
EOR
This UserTag works flawlessly if I call it like this:
<PRE>
[test-tag arg1="foo" arg2="bar" arg3="[nitems]"]this is another arg
[/test-tag]
</PRE>
It prints out:
Arg Value is: foo
Arg Value is: bar
Arg Value is: 1
Arg Value is: this is another arg
Which is what I expect.
According to the manual in the section on user defined tags, it says that
I can use safe_tag to make the same call within Perl.
So, I tried:
[perl interpolate=1]
my $temp = safe_tag('test-tag','foo','bar','[nitems]','another
arg');
return $temp;
[/perl]
However, what I get is:
Arg Value is:
I.e. the value is null or blank. From this, I think the calling
convention for safe_tag() calls to user tags isn't the same as the direct
inline calling convention.
Does someone have any idea how to make this work? Are references being
passed or something?
To test this, I defined another UserTag that uses references and tried to
find out what is actually passed to it:
UserTag test-tag2 Interpolate 1
UserTag test-tag2 Order arg1 arg2 arg3
UserTag test-tag2 Routine <<EOR
sub {
my $output;
my $value;
my $type;
my $numargs = scalar @_ ;
$output = 'Total args: ' . $numargs . '.\n';
for $value (@_)
{
$type = ref $value;
if($type)
{
$output .= "Arg type is: $type, value is:
$$value\n";
}
else
{
$output .= "Arg value is: $value\n";
}
}
return $output;
}
EOR
When I use the inline perl:
<PRE>
[perl interpolate=1]
my $temp = safe_tag('test-tag2','foo','bar','[nitems]','another
arg');
return $temp;
[/perl]
</PRE>
I get the following printed on my web page:
[test-tag2]
??!?!??!???
What is it doing?? It almost appears like it is returning a reference to
the routine or something. It isn't calling the user tag routine.
Can anyone help?
Best,
Kyle
-
To unsubscribe from the list, DO NOT REPLY to this message. Instead, send
email with 'UNSUBSCRIBE minivend-users' in the body to Majordomo@minivend.com.
Archive of past messages: http://www.minivend.com/minivend/minivend-list