[LON-CAPA-users] Scope of variables

Guy Albertelli II lon-capa-users@mail.lon-capa.org
Fri, 16 Jun 2006 12:27:43 -0400 (EDT)


Hi Brew,

> I am wondering about the scope of variables in scripts (I'm trying to track
> down a couple of lingering problems).
> 
> I build a problem composed of two parts. Each part imports a library
> section of code, including a perl script for randomization. Are the
> variables in conflict? I'm assuming they are local to the <part>, but maybe
> that is not true - maybe they are all global? The two scripts could be
> interfering with each other?
> 
> Is there a documentation page describing the scope of perl script variables
> within LonCapa?

All variables are global to a .problem

You can use the perl my functionality to contain the scope of
variables to a single <script> block.

For example:
<script type="loncapa/perl">
my $a='2';
</script>


-- 
guy@albertelli.com   0-7-1-8-27,137