in reply to Relative Merits of References

References are useful to pass data to functions. Using references, you pass a single scalar to the function, so perl doesn't have to copy the entire thing. Update: And they are also useful to create complex data structures. A hash of hashes is really a hash of references to hashes.

--
David Serrano

Replies are listed 'Best First'.
Re^2: Relative Merits of References
by blazar (Canon) on May 11, 2006 at 14:29 UTC

    Indeed references are just great! OTOH I have also seen very bad examples of programs abusing references in every place. I remeber this guy who kept passing stuff around referencing and dereferencing all the time, and in fact at one point he got stuck! Had he used @arrays and %hashes in the first place, is code would have been much KISSer.

Re^2: Relative Merits of References
by pbeckingham (Parson) on May 11, 2006 at 14:54 UTC

    Thanks David

    Understood, when passing by reference is needed, having a reference around is handy, but then creating one using

    \%h
    is not exactly complicated. I'm wondering if there are any reasons to choose one over the other - this example doesn't seem to qualify.



    pbeckingham - typist, perishable vertebrate.