in reply to Re: Array value changing for some reason
in thread Array value changing for some reason
tosub reverseArray { for(my $i=0;$i<scalar(@_);$i++){ @{$_[$i]} = reverse @{$_[$i]}; } }
did the trick!sub reverseArray { my @arr = @_; for(my $i=0;$i<scalar(@arr);$i++){ $arr[$i] = [reverse @{$arr[$i]}]; } }
So, if I understand it correctly, a subroutine can change variables from the function it was called from.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Array value changing for some reason
by kschwab (Vicar) on Dec 31, 2018 at 23:37 UTC | |
by jwkrahn (Abbot) on Jan 01, 2019 at 02:23 UTC | |
by Silt (Novice) on Jan 01, 2019 at 09:40 UTC | |
by poj (Abbot) on Jan 01, 2019 at 16:34 UTC | |
|
Re^3: Array value changing for some reason
by AnomalousMonk (Archbishop) on Jan 01, 2019 at 00:56 UTC |