in reply to Re^2: Why doesn't this die with "Can't use an undefined value as an ARRAY reference"?"
in thread Why doesn't this die with "Can't use an undefined value as an ARRAY reference"?"

But what does this even mean? Why would anybody do this?

I would guess that it is maybe just a simplification of a different case; using for as a topicalizer can be pretty useful. Clicking through the commits seems to show that the change to scalar was a bugfix resulting from the discussion in #24346. I found that an enlightening point was: "Since scalar is just a directive to change context, I don't see why it should change *anything* else."

In general, I think what this boils down to is a problem caused by autovivification, which, while of course powerful and nice, is also sometimes the source for such confusion. There is of course no autovivification; from CPAN, but personally I like to just be explicit and use exists and friends to avoid things vivifying when I don't want them to.

  • Comment on Re^3: Why doesn't this die with "Can't use an undefined value as an ARRAY reference"?"
  • Select or Download Code