#!/usr/bin/perl -w use strict; my %hash; build_hash(\%hash); print "$_ : $hash{$_}\n" foreach(keys %hash); sub build_hash { my $hash_ref = shift; $hash_ref->{'key1'} = "foo"; $hash_ref->{'key2'} = "bar"; }