#!/usr/bin/perl use strict; use warnings; my @value_pairs = qw( one abc two xyz one def ); my %hash; while (@value_pairs) { my $key = shift @value_pairs; my $value = shift @value_pairs; push @{$hash{$key}}, $value; } for my $key (keys %hash) { print "key $key has values: ", join(', ', @{$hash{$key}}), "\n"; } __END__ key one has values: abc, def key two has values: xyz