Hi all,

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

sub read_index {
    blablabla
    return (%author_indexlines, %poem_lines, @alphabet_index);
 }
 
 sub write_index {
    my (%author_indexlines, %poem_lines, @alphabet_index) = shift;
    blablabla
}

    write_index(&read_index);
    
I thought that this might be achieved returning references to the respective arrays 
and hashes and dereference them after passing, but since the elements have local scope 
in the read_index sub, I am not sure if this might work:

sub read_index {
    blablabla
    return (\%author_indexlines, \%poem_lines, [EMAIL PROTECTED]);
}

sub write_index {
    my ($author_ref, $poem_ref, $alphabet_ref) = shift;
    my @author_index = @$author_ref;
    blablabla
}

Any hints appreciated,

Jan
-- 
These are my principles and if you don't like them... well, I have others. - Groucho 
Marx

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to