my @data = map{ $count{$_} || 0 } qw(CLEAN SPAM INFECTED BANNED BAD-HEADER REJECTED); Why map{ $count{$_} || 0 } ? qw(CLEAN SPAM INFECTED BANNED BAD-HEADER REJECTED) # here you create an array for count values?