Your first mistake was using map as a function and not a keyword. You should have written
for my $arr ( @results ) {
...
my @row = map { val( $_ ) } @$arr;
...
}
The bug is still there, but it's clearer now that you're working in list context. At that point, you can fix it either by returning an explicit undef from val() (the bad way) or modifying your map body to be
val( $_ ) || undef (the good way).
My criteria for good software:
- Does it work?
- Can someone else come in, make a change, and be reasonably certain no bugs were introduced?