in reply to Why are these undefs different?

Consider this:

use Data::Dumper; use List::Util qw(first); my @x = ({"aaa" => 100}); [grep { $_->{"aaa"} < 4 } @x]->[0] = 'foo'; (first { $_->{"aaa"} < 4 } @x) = 'foo';

Line 6 (grep) executes fine. Line 7 (first) dies with:

Can't modify non-lvalue subroutine call of &List::Util::first in list assignment at foo.pl line 7, near "'foo';"

You're putting the results of your grep into an arrayref. That arrayref and its elements are lvalues—they can be assigned to—so autovivification can happen to them.