use strict; use warnings; use Data::Dumper; my %stuff; foreach (do { open my $test, '<', 'test.txt' or die "I/O Error: $!\n"; local $/; split /[,\r\n]+/, <$test>; }) { my ($key, $value) = split /=/; $stuff{$key} = $value; } print Dumper \%stuff;