# Perl usage in skip logic

Hi,
could you help me to understand how to use perl in skip logic?
I need to count respondents with certain criteria in 40 questions, and if there are less then 10 out of 40 than go to certain question (skip to).

Thanks,
Alex

If you are talking about answering 10+ items in a question, you can use the NumChecked function in a skip.

e.g. if Q1 is answered greater than 10 items then skip ...

Use NumChecked(Q1)>10 as your skip logic.

If you need to apply 40 conditions across 40 different questions / criteria sets, you can setup a parent list with a description for each criteria.

Parent list (call it CriteriaList)
1-Q1 criteria (example - Q1=1)
2-Q2 criteria (example - Q2_5=1)
3-Q3 criteria (example - Q3>2)
4-Q10 criteria (example - Q10_r1=3)
and so on ...

Now create a constructed list using the parent list above. Call it CriteriaConList.
```Begin Unverified Perl

if (VALUE("Q1")==1)
{
}

if (VALUE("Q2_5")==1)
{
}

if (VALUE("Q3")>2)
{
}

if (VALUE("Q10_r1")==3)
{
}

End Unverified
```

As each criteria set is true, the respective item is added to the constructed list - CriteriaConList.

Now in your skip logic, you can use ListLength(CriteriaConList)>10, then skip ...
answered May 16, 2016 by Platinum (67,375 points)
edited May 16, 2016
If you don't need the database to store which criteria was met, you can alternatively put the Perl directly into the skip logic.  A skip with this logic will do the same thing without the use of lists:

```Begin Unverified Perl
my \$var = 0;
if (VALUE('Q1') == 1) {
\$var++;
}
if (VALUE('Q2_5') == 1) {
\$var++;
}
if (VALUE('Q3') > 2) {
\$var++;
}
if (VALUE('Q10_r1') == 3) {
\$var++;
}
# More criteria...
return \$var > 10;
End Unverified
```
The two positives with the list building is it does assist with the testing and analysis. If these are not relevant to you, Zachary's method is spot on (as usual).
You've got me convinced.  When Perl gets even a little complex, it can become a nightmare to debug.  List building can surely provide a valuable clue for finding what is wrong.