MiniVend Akopia Services

[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date ][Minivend by thread ]

difference between [perl] and [calc]




I just did a test to see what was happening with some of my Perl code.  It
was not returning what I expected. 

I had this:

[perl values interpolate=1]
	my $msg = '[data session ship_message]';

	return length($msg);
[/perl]

When I just put [data session ship_message] in the HTML, I get the price
of shipping (not quite what I would expect).  In the case of the tests,
that was 26.72. So, my Perl script should return 5, right?  WRONG.  It
returns 27.  Yep. 27.

So I tried again:

[calc]
	my $msg = '[data session ship_message]';

	return length($msg);
[/calc]

And, I get... 5.

The Perl script gets the length of the _uninterpolated_ string.  All I can
guess is that the interpolate flag is applied differently than I thought.
I understood that all MV tags would be interpolated and then the resulting
string would be "eval"ed in Perl.  I guessed incorrectly.

This clears up a lot of small problems I have had over the last couple of
weeks:

[perl interpolate=1] != [calc] !!!!!

So, now I need to go and replace a bunch of [perl] tags with [calc]...
Sigh.  This is quite annoying as I need to run some [perl] code on
elements in the 'values' hash, but I need some interpolated values too.

Has anyone else run into this kind of thing?  Is this a bug or a feature?

Best,
Kyle







Search for: Match: Format: Sort by: