in reply to Re: Re: Re: Re: Memory Use and/or efficiency passing scalars to subs
in thread Memory Use and/or efficiency passing scalars to subs

knexus,
The code that perrin and I provided does exactly what you want. First pass a reference to the scalar to the sub instead of the scalar itself.
modify_large_scalar(\$large_scalar);
Notice the \ in front of the $large_scalar. This makes an explicit reference to the variable. Then inside the sub, shift off the reference into a properly named variable.
sub modify_large_scalar { my $large_scalar_ref = shift; # Code to modify $$large_scalar_ref }
I have been following this thread and you said that it was taking up to 13 hours to run. Chances are there are other ways to improve the efficiency of the code. You might want to post all of your code (inside readmore tags if it is long) to see if we can't come up with some more efficient ways of accomplishing the same thing. Additionally, you should look into modules like Benchmark and Devel::Profile to see if the problem is where you think it is.

Cheers - L~R