in reply to Uninitialized or not?
I suspect that the first case is considered "left-hand context", that is, potentially "being assigned to", which triggers autovivification while the second case is purely "right-hand context" (just getting the value) and so doesn't trigger autovivication.
This makes some sense since you can assign to $_ inside of the foreach, but I'm not a big fan of the way it works.
I'd rather just have an option like strict that just turns off all autovivification (it requires a bit more careful coding but can also catch certain types of coding errors for you -- and I prefer that style of coding, it making the intent clearer).
Update: How did you get the impression that I was proposing anything other than that, Aristotle? strict is disabled by default. "turns off" also implies that autovification being "on" would be the default.
- tye
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Uninitialized or not?
by Aristotle (Chancellor) on Nov 27, 2002 at 19:21 UTC |