Hello asqwerty, and welcome to the Monastery!
You already have the answer you were looking for. I just want to point out that the line:
%dfs = map {$_ => ()} @pref;
is incorrect. You can see this by printing the contents of %dfs (using Data::Dumper) immediately after that line:
$VAR1 = { 'brain' => 'lung', 'kidney' => undef };
When interpolated into an array or hash, the empty list () effectively disappears. I think you meant to write:
%dfs = map {$_ => []} @pref;
which works correctly, although
%dfs = map {$_ => undef} @pref;
also works.
Here is some good advice: Get into the habit of including the lines
use strict; use warnings;
at the head of every script. In this case, warnings would have shown you the problem:
Odd number of elements in hash assignment at ... line 6.
Hope that helps,
Athanasius <°(((>< contra mundum
In reply to Re: populating a HoA with regexp
by Athanasius
in thread populating a HoA with regexp
by asqwerty
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |