in reply to passing of variables

this only lasts locally in this sub

# Creates a hash %t that has the same contents as %toys my %t = %{$_[0]}; # Modifies %t (which is unrelated to %toys) $t{'leggo'} = "yes";

[$_[0]{'leggo'} = "yes";] is darned ugly!

Since you're not changing the reference itself (only that to which it refers), you can copy the reference into a more suitably named variable.

my ($toys) = @_; $toys->{'leggo'} = 1;

Note that 1 and 0 (or undef) are usually used for boolean. It's not that using "yes" is problematic, it's that "no" isn't false. Formatting outputs (e.g. converting to "yes" and "no") should be done on output.

Replies are listed 'Best First'.
Re^2: passing of variables
by itsscott (Sexton) on May 06, 2011 at 18:00 UTC
    Agreed on the last comment, I choose my example a little poorly I suppose :-) Thanks for the help to monks!!