#!/usr/bin/perl use strict; use warnings; my %hash = start_all_programs(); print $hash{pc1}->{program}; sub start_all_programs{ my %tmp; for my $pc ('pc1','pc2'){ $tmp{$pc}->{program} = 'test'; } return %tmp; }