open HANDLE, 'testhash.txt' or die "Can't open: $!"; my $data = ; close HANDLE; chomp $data; my %hash; foreach my $pair (split /'/, $data) { next if $pair eq ''; # empty 'item' before first comma next if $pair =~ /^,$/; # throw away commas between pairs my ($key, $value) = split /,/, $pair; $hash{$key} = $value; } # demo use of the hash to access results foreach my $key (keys %hash) { print "$key $hash{$key}\n"; }