Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Testing for definition of references

by jsprat (Curate)
on Jun 26, 2003 at 18:10 UTC ( [id://269342]=note: print w/replies, xml ) Need Help??


in reply to Testing for definition of references

Straight from the horse's mouth (perldoc -f defined):

Use of "defined" on aggregates (hashes and arrays) is deprecated. It used to report whether memory for that aggregate has ever been allocated. This behavior may disappear in future versions of Perl. You should instead use a simple test for size

HTH...

  • Comment on Re: Testing for definition of references

Replies are listed 'Best First'.
Re: Re: Testing for definition of references
by DBX (Pilgrim) on Jun 26, 2003 at 18:18 UTC
    Yes, but if you follow what the perldoc says to do for regular arrays and hashes, but use it on a reference like:
    if(@$arrayref)
    and it is not defined, Perl will crash. This is what I'm trying to avoid.
      I'm missing something here. You want to know if it is a reference, but you want to avoid using ref. Is there a reason why (besides not being a fan)? That's exactly what ref was designed to do.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://269342]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2024-04-18 16:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found