my %data = (); # initialize hash while () { # assume you have the file open already my ($key, $value) = split(/=/, $_, 2); $data{$key} = $value; }