|XP is just a number|
HTML::Template Interpolation Error?by hbo (Monk)
|on Aug 16, 2004 at 20:58 UTC||Need Help??|
hbo has asked for the
wisdom of the Perl Monks concerning the following question:
Some code I wrote came back to me today with the complaint that it was blowing up with an error:
The code in question looked like this:
So it looks like the 'rcadd_list' parameter is getting swallowed. To make a long story short, changing the code like this:
Fixed it up.
I'm relying on interpolating the return value of a CGI call into the parameter list of an HTML::Template call throughout this code, not to mention throughout my career. Why does it fail in this case?
blokhead supplied my answer.
checkbox_group() returns a list in list context. HTML::Template::param takes a list of key/value pairs. The first pair was thus
where the second parameter is the first <input> tag returned by the checkbox_group call. But then the next <input> tag becomes a parameter tag for HTML::Template::param(), which is totally fubar.
Prepending an empty string as above forced scalar context, which made checkbox_group return a space-seperated list of input tags, which was just what I wanted. I ended up changing the code like so:
Which makes the whole thing more explicit, in case anyone as thick as I comes along to work on this in the future. 8)
Thanks to blokhead for the correct answer!
"Even if you are on the right track, you'll get run over if you just sit there." - Will Rogers