M
mmasroorali
Dear All,
I am confused here. I want to return multiple values from a subroutine
where the first two are one dimensional arrays, the third one is a two
dimensional array. To return them together I had a naive approach like
this (rebuilt as a minimal example),
I want to assign ss1 to s1 etc.
#!/usr/bin/perl
use strict;
use warnings;
my (@s1, @s2, @s3) = mysub();
print "@s1\n";
print "@s2\n";
print "@s3\n";
sub mysub
{
my @ss1 = ("1a", "1b", "1c");
my @ss2 = ("2a", "2b", "2c", "2d");
my @ss3 = (["3aa", "3ab"], ["3ba", "3bb", "3bc"], ["3ca"]);
return (@ss1, @ss2, @ss3);
}
I find that every thing gets assigned to @s1, where the last three are
addresses (possibly from @ss3).
Could please tell me how I can get the intended effect?
Regards.
I am confused here. I want to return multiple values from a subroutine
where the first two are one dimensional arrays, the third one is a two
dimensional array. To return them together I had a naive approach like
this (rebuilt as a minimal example),
I want to assign ss1 to s1 etc.
#!/usr/bin/perl
use strict;
use warnings;
my (@s1, @s2, @s3) = mysub();
print "@s1\n";
print "@s2\n";
print "@s3\n";
sub mysub
{
my @ss1 = ("1a", "1b", "1c");
my @ss2 = ("2a", "2b", "2c", "2d");
my @ss3 = (["3aa", "3ab"], ["3ba", "3bb", "3bc"], ["3ca"]);
return (@ss1, @ss2, @ss3);
}
I find that every thing gets assigned to @s1, where the last three are
addresses (possibly from @ss3).
Could please tell me how I can get the intended effect?
Regards.