in reply to Subroutine Parameters
If you:
my (@array, ...) = (list);
@array gets the entire contents of the list. Your sub flattens (@$age, %$home) into a list of scalars and they all end up in @age_r. You don't even need the sub to be involved. Consider:
use strict; use warnings; my @age = (20, 30); my %home = (Kelvin => "Tokyo", Andrew => "New York"); my (@age_r, %home_r) = (@age, %home); print "@age_r";
prints:
20 30 Kelvin Tokyo Andrew New York
However:
... my ($age_r, $home_r) = (\@age, \%home); print "@$age_r";
prints:
20 30
so for your sub you should return a list of references then use the syntax as shown above. In your sub you simply:
return ($age, $home);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Subroutine Parameters
by radicalfix (Initiate) on May 31, 2007 at 06:37 UTC |