leocharre has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use strict; my $anon_array = [qw(one two three)]; # pass it to mysub mysub({ list => $anon_array }); #now pass it to mysub again, but reversed... # i can't figure out how to take an anon array and # pass it reversed on the spot... mysub({ list => \(reverse @{$anon_array}) }); sub mysub { my $args = shift; for ( @{$args->{list}} ){ print $_."\n"; } return; }
Basically.. I have an annon array, i can use it - send it as argument around my code.. how would i reverse it as it is being sent as an argument???
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: how to reverse an array refference and return an array reference on the spot
by friedo (Prior) on Aug 23, 2006 at 14:27 UTC | |
by duckyd (Hermit) on Aug 23, 2006 at 16:40 UTC | |
|
Re: how to reverse an array reference and return an array reference on the spot
by davorg (Chancellor) on Aug 23, 2006 at 14:29 UTC | |
by betterworld (Curate) on Aug 23, 2006 at 18:30 UTC |