more useful options | |
PerlMonks |
Re: Why do I (sometimes) get a REF ref and not a SCALAR ref? (silly)by tye (Sage) |
on Jun 23, 2016 at 18:39 UTC ( [id://1166403]=note: print w/replies, xml ) | Need Help?? |
Yeah, you can explain this behavior. But it is, frankly, stupid. \\$x is, indeed, a reference to a scalar and so ref should return "SCALAR". Having a special case for "reference to a scalar that happens to currently be holding a reference" is silly. It just leads to code having to check for both "SCALAR" and "REF", adding complexity. It makes about as much sense as having ref(\\\$x) return "REFREF" or ref(\\@x) return "ARRAYREF" or ref([]) return "EMPTYARRAY". - tye
In Section
Seekers of Perl Wisdom
|
|