sub testfunc (\%) { my ( $href ) = @_; my $key = "file4"; my $insert_val="host1"; my $insert_val2="foo"; #push(@{$href{$key}}, $insert_val); #push(@{$href{$key}}, $insert_val2); foreach my $file (keys %$href) { print "The content of $file is:\n"; foreach my $line ( $href->{$file} ) { print "\t$line\n"; } } } my %hash = ( file1 => [ 'host1', 'bla', 'foo', ], file2 => [ 'host2', 'host1', '..', ], file3 => [ 'x', 'host2', 'host1' ] ); testfunc(%hash);