return array/hash ref from function

From: Andrew Gaffney (agaffney_at_skylineaero.com)
Date: 05/12/04


Date: Wed, 12 May 2004 14:12:50 -0500
To: beginners <beginners@perl.org>

I have a number of functions in a program I'm writing that return a reference to
an array or hash. In the functions, I declare the variable to return with 'my'
which I'm finding out is bad. Should I declare variables to return from a
function with 'our'? Do I need to make sure I don't have conflicting variable
names from other functions? What pitfalls do I need to know about when doing this?

-- 
Andrew Gaffney
Network Administrator
Skyline Aeronautics, LLC.
636-357-1548


Relevant Pages

  • RE: Array de-referencing problem
    ... But I guess it's better to use an array reference? ... Conversation: Array de-referencing problem ... The values of a hash can only be scalars! ...
    (perl.beginners)
  • Re: Complex Objects in Perl
    ... > sub-object is made up of a number of different objects and an array of an ... Objects in Perl are implemented as a reference to an anonymous hash. ...
    (comp.lang.perl)
  • Re: Looking to improve program
    ... You generally should declare your variables in the smallest scope ... array. ... Now that you have the hash, you can use it instead of four nearly ... There's also no real reason to be assigning ...
    (comp.lang.perl.misc)
  • Re: complex data structure
    ... reference to an anonymous one-key hash. ... store, just put them in the array: ... stores a reference to an anonymous 4-element array into scalar variable ...
    (comp.lang.perl)
  • Re: Accessing hash of arrays?
    ... I want to archive to hash indexed by the target folder: ... I am not trying to slice an array. ... to be a reference to an array. ...
    (perl.beginners)