Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Return hash from a com object. ?

by kcott (Archbishop)
on Jun 11, 2016 at 05:00 UTC ( [id://1165387]=note: print w/replies, xml ) Need Help??


in reply to Return hash from a com object. ?

G'day cdlvj,

Disclaimer: I can't help you with specifics of "perl dll created by perl Ctrl"; sounds like a MSWin thing (with which I'm unfamiliar).

In many functions, you'll only be interested in the hash's keys and values; the name of &readDirectory suggests it would fall into this category. In these cases, your best choice will probably be:

return { %rlist };
  • There are no references to %rlist when it goes out of scope at the end of &readDirectory: cleanup can occur.
  • All callers have a hash which is decoupled from all other callers' hashes and the original %rlist.

In other functions, particularly those that need to modify the hash in some way, a reference to the original hash may be important. In these cases, your best choice will probably be:

return \%rlist;
  • There is one reference to %rlist when it goes out of scope at the end of &readDirectory: cleanup cannot occur.
  • All callers have a reference to the same hash; any of which could be modifying the hash in some way, at any time, without notice.

See also: perlreftut, perldsc and perlref.

— Ken

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (6)
As of 2024-04-25 11:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found