itsscott has asked for the wisdom of the Perl Monks concerning the following question:
Thank you in advance for any insight to my non-grasping of pointer/var handling in perl. I'm used to C and don't have too much trouble there!# call the sub with a local hash play_around(\%toys); sub play_around { my %t = %{$_[0]}; # I found this the only way to get the has in properly, # otherwise it came in scalar, and mixing and matching # hash and scalars made me choose to load this way, if # it's wrong, please correct me. $t{'leggo'} = "yes"; # this only lasts locally in this sub $_[0]{'leggo'} = "yes"; # this will modify the actual %toys which is what I want. # But this is darned ugly! and with a number of # hashes / scalars it's a pain. Is there not a better # way, or have I crossed the line into being a # bad practice perl programmer? }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: passing of variables
by wind (Priest) on May 06, 2011 at 17:37 UTC | |
by itsscott (Sexton) on May 06, 2011 at 17:58 UTC | |
Re: passing of variables
by ikegami (Patriarch) on May 06, 2011 at 17:46 UTC | |
by itsscott (Sexton) on May 06, 2011 at 18:00 UTC | |
Re: passing of variables
by tchrist (Pilgrim) on May 06, 2011 at 18:07 UTC | |
by itsscott (Sexton) on May 06, 2011 at 18:13 UTC | |
by John M. Dlugosz (Monsignor) on May 07, 2011 at 01:07 UTC | |
by itsscott (Sexton) on May 07, 2011 at 02:33 UTC | |
by John M. Dlugosz (Monsignor) on May 07, 2011 at 03:50 UTC | |
by GotToBTru (Prior) on May 06, 2011 at 20:47 UTC | |
Re: passing of variables
by jwkrahn (Abbot) on May 06, 2011 at 17:40 UTC |