No such thing as a small change | |
PerlMonks |
Using undef scalar as arrayrefby shemp (Deacon) |
on Aug 12, 2005 at 20:00 UTC ( [id://483386]=perlquestion: print w/replies, xml ) | Need Help?? |
shemp has asked for the wisdom of the Perl Monks concerning the following question:
Hi all, I was playing with some code that uses an arrayref in various places, and started getting errors when i added some code and the arrayref was undef. Originally, there was something like: (all code has strict & warnings on, these are just snippets)
This worked ok, even when $arrayref == undef. So then i added an if conditional to the method: This resulted in a fatal error: Can't use an undefined value as an ARRAY reference at ...
My co-worker and I discussed this and decided that it was an rvalue versus lvalue issue. But our resolution still doesn't sit very well in my mind.
Update:This is incorrect, it creates a fatal error. end update But thats not cool, and results in a warning too. Anyway, in the end i did the if statement as: (perhaps i should be doing a ref test also, but the value of $arrayref is always set by the same method.) So im looking for more insight into exactly why this is all behaves like it does. I sort of understand, but not completely. I use the most powerful debugger available: print!
Back to
Seekers of Perl Wisdom
|
|