recentpopularlog in

therobyouknow : return   12

How do I return multiple variables from a subroutine?
main
{
my ( $hashRef1, $hashRef2 ) = function1();

function2( $hashRef1, $hashRef2 );
}

sub function1
{
my %hash1 = ();
my %hash2 = ();
# ... some code ...
return( \%hash1, \%hash2 );
}

sub function2
{
my ( $paramHashRef1, $paramHashRef2 ) = @_;

# ... deref by %$paramHashRef1 and %$paramHashRef2 etc
}

main();
perl  hash  return  argument  parameter  between  returning  function  multiple  subroutine  programming  language  computing  syntax  method  howto  advice  work  reference  dereference  passby 
march 2010 by therobyouknow

Copy this bookmark:





to read