#!/usr/bin/perl use strict; my %hash; my @array; # here you pass the references and get them back my ($ref_hash,$ref_array) = load_variables(\%hash,\@array); # and then you pass these for printout print_variables($ref_hash,$ref_array); ################## sub load_variables { ################## my %hash1 = %{ shift() }; my @array1 = @{ shift() }; ### Load array @array1 = ('a','b','c'); ### Populate the hash (for each character ### set the hash to the next map { my $tmp = ++$_; $hash1{$_} = qq($tmp); } @array1; ### Return the references return (\%hash1,\@array1); } ################### sub print_variables { ################### my %hash2 = %{ shift() }; my @array2 = @{ shift() }; map { printf q(hash: ).qq($hash2{$_}\n) } keys %hash2; }