Stuart White wrote:

> I'm having trouble returning a hash from a subroutine,
> and an array from a different subroutine.  "Beginning
> Perl" said I could return a list, I can't get it to
> work.  Must the hash and array really be a reference
> to the hash and array in order to return them?

In brief, *Yes*  You should get comfortable with this, if you have any desire to be a 
programmer.  No matter what language you work in, power programming will largely 
depend on an understanding
of references, and their close cousins, pointers.

In not so brief, yes and no.  It seems like the code should have returned a list of 
elements.  Unfortunately, there is only one element, since you overwrite the whole 
array each time through
the loop.

I'm pretty sure the logic would have p[opulated the array other than this.  It would 
still be quite wasteful, since this whole list would have to be recopied, where an 
anobynous hash would have
already been packed for transit.

I would really suggest that you overcome whatever resistance you have to working with 
references.  If you approach them fresh, they are really rather straightforward.  Put 
a little energy into
getting over this hump in the learning curve, and you can reap benefits in all your 
programming efforts.

Joseph



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to