hey there oK I just read about reference dereference. so before I call on the package I reference the hash and then when I am done with the package and in the program I dereference the hash? yes?
I know how to, just not when to.. but from what I read I can reference the hash anytime before, as long as any changes in the values are done via the reference var, not the original hash? yes? and from what you wrote I have to declare the var with "my". have I got it? Thanks for your pointer....it seems to have been the missing link! Lou ----- Original Message ----- From: "Chris Devers" <[EMAIL PROTECTED]> To: "Luinrandir" <[EMAIL PROTECTED]> Cc: "Perl Beginners List" <beginners@perl.org> Sent: Friday, September 02, 2005 8:34 PM Subject: Re: Just need a yes or no answer on passing a hash to a package On Fri, 2 Sep 2005, Luinrandir wrote: > Can I pass a hash to a package? Yes. (Hint: passing any complex data around is generally best done with the use of references, so that's the area you need to be studying up on.) Pseudocode: my $result = go_do_something_with( \%this_hash ); ... sub go_do_something_with { my $hashref = shift; ... return $result; } You just have to get the hash data back out of $hashref this way. If you need to pass multiple hashes, the same idea applies: my $new_result = act_upon( \%hash_a, \%hash_b, \%hash_c ); ... sub act_upon { my ( $a_ref, $b_ref, $c_ref ) = @_; ... return $result; } And, again, you just need to unpack $a_ref, $b_ref, and $c_ref in exactly the same way you unpacked $hashref in the first example. If you need to pass more complex data structures, this is the general approach to doing so that most people seem to use. -- Chris Devers >¯)làwÓ>î¬ ---------------------------------------------------------------------------- ---- > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > <http://learn.perl.org/> <http://learn.perl.org/first-response> > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>