develooper Front page | perl.beginners | Postings from January 2004

Re: Passing several arguments

Thread Previous | Thread Next
From:
drieux
Date:
January 28, 2004 20:34
Subject:
Re: Passing several arguments
Message ID:
2DFC1F68-51FF-11D8-B585-0030654D3CAE@wetware.com

On Jan 27, 2004, at 3:26 AM, Jan Eden wrote:
[..]
> I have a subroutine which fills into several hashes and arrays 
> (%author_indexlines, %poem_lines, @alphabet_index etc). How can I 
> return those variables and pass them to another subroutine? This does 
> not work, of course
[..]

perldoc -q "How can I pass/return a {Function, FileHandle, Array,"

remember that your core signature is

	my @return_list = function(@arglist);

so the only way that you can return more than one
array or hash will be by passing their refs

	my ($auther, $poem, $index) = function(@arglist);
	....

	sub function {
		....
		(\%author_indexlines, \%poem_lines, \@alphabet_index, $etc)
	}

then you re-ref them as

	while( my ($k,$v) = each %$author )
	{
		....
	}

ciao
drieux

---


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About