I want to preserve the value of the original array @num after the operation at second. What is the best way to do that?Just take a copy of it in your second sub and work on that. For example:
Cheers,sub second { my $num_ref = shift; my @copy_of = @$num_ref; push(@copy_of, 6); my $sum = 0; foreach (@copy_of) { $sum += $_; } return $sum; }
In reply to Re: Preserve the value of original array
by McDarren
in thread Preserve the value of original array
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |