Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Arrays and Hashes


Do arrays and/or hashes support "splitting" the source and output coding?

For example, I would place this content in the global header...

my @Scores = (55, 22, 4, 17);
my $FirstScore = 0;

...then place this code where I want the actual output:
$FirstScore = $Scores[0];

A few initial trials fail but I am not sure if they fail because you simply cannot do this or because there's something incorrect about my code.

Any ideas?
asked Dec 14, 2018 by WTW_cal Bronze (1,595 points)

1 Answer

+1 vote
I don't believe what you're describing is built into the software, as each Perl script is executed in a scope independent of other scripts.  However, you may still be able to achieve your desired functionality by calling an external .pl file.  This post can help you get started if this option seems useful to you:


Alternatively, this could be done using JavaScript rather than Perl.  A global JavaScript variable defined in the survey header would be available on every page of the survey.  However, there are limitations to what JavaScript can do; depending on what you are looking to do, you may not be able to convert your code to use JS.  You also would not want to use JS if handling secure information you don't want the respondent to have access to.
answered Dec 14, 2018 by Zachary Platinum Sawtooth Software, Inc. (181,275 points)