http://www.perlmonks.org?node_id=362247


in reply to Passing hashes to subroutines

Your declaration for array and hash are wrong. If you use warnings you'll see why.

This modified code should do what you want:

#!/usr/bin/perl -w use strict; my %hash = (a=>'A', b =>'B'); # parens, not braces my @array = (1,2,3); # parens, not brakets my $scalar = 'This is a scalar'; # Pass an array REFERENCE dummy(array=>\@array, scalar=>$scalar, hash=>{a=>'A', b =>'B'}); dummy(array=>\@array, scalar=>$scalar, hash=>\%hash); my $hashref = \%hash; dummy(array=>\@array, scalar=>$scalar, hash=>$hashref);

HTH