in reply to Sometimes undef is initialized and sometimes not when hash values are fed to grep
What's happening in "third try" is that you are passing an alias to map which is forcing an autovivification.
The second try is only a copy.
One workaround would be to surround every value with quotes "$h{bla}" , to enforce a copy.
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
FootballPerl is like chess, only without the dice
°) I'll link to it ... here it is: unexpected modify hash in a distance with grep { $_ }
Well, it's the last thread you started and the one you linked to (!?!)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Sometimes undef is initialized and sometimes not when hash values are fed to grep
by LanX (Saint) on Feb 11, 2020 at 16:47 UTC | |
by haukex (Archbishop) on Feb 11, 2020 at 16:51 UTC | |
by LanX (Saint) on Feb 11, 2020 at 16:54 UTC |