map returns a list so the solution to your missing value conundrum is to return an empty list for suppressed values. I'm not sure I'd solve this particular problem using a map and the following technique, but the technique is worth knowing about in any case:
use strict; use warnings; my %info = map {chomp; my @parts = split '='; @parts == 2 && length $parts[1] ? @parts : () } <DATA>; print "$_: $info{$_}\n" for sort keys %info; __DATA__ key=value nokey=
Prints:
key: value
In reply to Re: map a hash with a default value or exclude
by GrandFather
in thread map a hash with a default value or exclude
by kayahk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |