[LON-CAPA-users] passing variables by ref in problem

Guy Albertelli II lon-capa-users@mail.lon-capa.org
Mon, 7 Feb 2005 11:48:53 -0500 (EST)


Hi Hon-Kie,

> It seems that when variables are passed to a sub routine by ref, the sub 
> routine cannot de-ref the variables. Is there a way to fix this?

Works fine for me:
<problem>
<script type="loncapa/perl">
$test="starting"
</script>
<startouttext />test value is $test<br /><endouttext />
<script type="loncapa/perl">
sub change {
    my ($ref)=@_;
    $$ref="finished";
}
&change(\$test);
</script>
<startouttext />test value now is $test<endouttext />
</problem>

In what way is it not working for you?


-- 
guy@albertelli.com  LON-CAPA Developer  0-7-3-2-