in reply to Returning multiple Hash references from a sub()

Instead, use: my ($foo, $bar, $baz) = ParseForExpDB2Params(@params);

References are scalars. Assigning a (part of a) list to an array or hash puts all remaining scalars in that list into that array or hash, even if the left-hand side of the assignment has more than one variable.

Example: ($foo, @bar, @baz) = (1..10); results in $foo containing 1, @bar containing the list equivalent to (2..10), and @baz containing nothing (it was assigned an empty list, so any contents were overwritten).

Additionally, with warnings enabled, you would receive a warning about an odd (3) number of elements assigned to a hash, which requires an even number of elements (key-value pairs).

Replies are listed 'Best First'.
Re^2: Returning multiple Hash references from a sub()
by moritz (Cardinal) on Sep 03, 2010 at 12:50 UTC
    In additional to AnonMonks excellent explanation I'd like to point you to perlreftut, which introduces you to the sublteties of references in Perl 5.

    Another good document is the Perl Data Structures Cookbook.

    Perl 6 - links to (nearly) everything that is Perl 6.