in reply to Preserve the value of original array
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; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Preserve the value of original array
by Anonymous Monk on Feb 14, 2006 at 06:16 UTC | |
by McDarren (Abbot) on Feb 14, 2006 at 06:20 UTC |