in reply to Re^3: Returning values from a sub routine.
in thread Returning values from a sub routine.

Sorry it didnt help, where in this sample code would your code go?
  • Comment on Re^4: Returning values from a sub routine.

Replies are listed 'Best First'.
Re^5: Returning values from a sub routine.
by suaveant (Parson) on Jul 31, 2012 at 19:38 UTC
    sub test { my (@names_all, @email_all); my @names = qw(Joe mary ann pete amy jerry Joe ann John John ); my @email = qw(joe@test.com mary@test.com ann@nowhere.com pete@here.com amy@ok.com jerry@b.com joe@test.com ann@nowhere. +com John@test.com John@ok.com); my %emails; my @names_combined = (@names,@names_all); my @emails_combined = (@email,@email_all); for my $name ( @names_combined ) { push @{$emails{$name}}, shift(@emails_combined); } return \%emails; }
    Not tested, but should get you going in the right direction. Maybe read some Perl tutorials or Learning Perl to get a better overall feel for the language.

                    - Ant
                    - Some of my best work - (1 2 3)