my %flag; .. $flag{'user'} = $user; .. $flag{'uid'} = $uid; ... ... return %flag; at the calling place use my %userflags = buildCommand(..) then access the values like $userflags{'user'} or use references return \%flag; at the calling place use my $userflags = buildCommand(..) then access the values like $userflags->{'user'}