in reply to Re^2: Putting Hash values into an array
in thread Putting Hash values into an array
You’re right! But at least warnings raises a red flag:
18:38 >perl -Mstrict -wE "foreach (my $RID) { say qq[\$RID = >$RID<]; +}" Use of uninitialized value $RID in concatenation (.) or string at -e l +ine 1. $RID = >< 18:43 >
I wasn’t expecting the loop to be entered at all, and Foreach Loops doesn’t seem to shed much light on the issue. But I’m guessing it’s the difference between a scalar undef and an empty list:
18:45 >perl -Mstrict -wE "foreach (my @RID) { say 'okay'; }" 18:46 >
Seems the foreach is treating $RID as a list containing one element (with the value undef), as though it were foreach (my @RID = (undef)):.
18:46 >perl -Mstrict -wE "foreach (my @RID = (undef)) { say 'okay'; }" okay 18:51 >
Thanks for pointing this out!
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|