in reply to Re: Returning arrays from a package
in thread Returning arrays from a package
> You cannot return multiple lists from a function in Perl
well the OP is trying to return multiple array-refs not lists, and the new'ish use feature qw/refaliasing/; allows these to be assigned to multiple @arrays. (see tst2())
use strict; use warnings; use Data::Dump qw/pp dd/; use feature qw/refaliasing/; no warnings "experimental::refaliasing"; sub tst { (\my %args) = @_; pp \%args; } tst({a=>1,b=>2}); sub tst2 { return [1..3],[4..7] } our (@a,@b); (\@a,\@b) = tst2(); pp \@b; pp \@a;
{ a => 1, b => 2 } [4 .. 7] [1, 2, 3]
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
FootballPerl is like chess, only without the dice
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Returning arrays from a package (feature qw/refaliasing/;)
by jcb (Parson) on Oct 02, 2019 at 01:08 UTC | |
by LanX (Saint) on Oct 02, 2019 at 11:38 UTC | |
by jcb (Parson) on Oct 02, 2019 at 23:41 UTC |