in reply to map a hash with a default value or exclude
prints:use warnings; use strict; use Data::Dumper; $Data::Dumper::Sortkeys = 1; my %info; while (<DATA>) { chomp; my ($k, $v) = split /=/; $info{$k} = $v if length $v; } print Dumper(\%info); __DATA__ a=5 b=6 c= d=7
This keeps the key, with a default value:$VAR1 = { 'a' => '5', 'b' => '6', 'd' => '7'
while (<DATA>) { chomp; my ($k, $v) = split /=/; $info{$k} = (length $v) ? $v : 666; }
|
|---|