... my %hash; open my $fh,'<', 'input.txt' or die "with style ($!)"; %hash = map /^Data_Type:([\S]+)\s*([^\n]+)/, <$fh>; # all happens here close $fh; ...