my %hashnew; my $current_key = undef; my $current_value = undef; while () { my ($key, $value) = assign_key_value_from_current_line ($_); $current_key = $key if defined $key; $hashnew{$current_key} = $value; }