SSI Script Functions Inside Perl

Last Updated: 25 Apr 2014Hits: 4828
I have the below script where I want to return options selected from dropdown box. If respondents select other specify, the 29th item, then it needs to display the text they entered. But my code is not working. What is the mistake? [% begin unverified perl if(VALUE("Q5A1_r1_c1") le 28) {return [%Label(Q5A1_r1_c1)%];} if(VALUE("Q5A1_r1_c1") eq 29) {return [%Q5A1_r1_c2%];} end unverified %]

There are a couple of things going wrong here. First, embedding SSI Script functions inside Perl requires close attention to capitalization. Whenever you are using SSI Script within Perl, the function name will almost always be capitalized. You can see this in the SSI Web Help files, under Unverified Perl Functions. There you will see a table that lists SSI Script and their Unverified Perl equivalents.

Second, keep in mind that many of our SSI Script functions are already Perl functions, so the [% ... %] is not necessary. In fact, it will generate an error if you try to embed them within each other. Instead, leave off the internal [% ... %] characters.

Here is the corrected code:

[% begin unverified perl

if(VALUE("Q5A1_r1_c1") le 28) {return LABEL("Q5A1_r1_c1");}

if(VALUE("Q5A1_r1_c1") eq 29) {return VALUE("Q5A1_r1_c2");}

end unverified %]