while () { chomp; # <== move the chomp here my ($key, $value) = split /;/; $calhash{$key} = $value; # not '= $key' }