John W. Krahn:
Jeff Pang wrote:
Noah:
sub exiting {
my ($hostname, %login) = @_;
Passing arguments like this has no such problem.
But you'd better pass the hash as a reference to the subroutine.
exitint($hostname, \%login);
sub exiting {
my $hostname = shift;
my %login = %{+shift};
What is the point of passing a reference if you are just going to copy
the whole hash anyway (which is what the OP was doing)?
If people want to change the hash's elements in subroutine and don't
want to influence the original one, then passing a copy is right.
Otherwise copy a hash is wasteful for memory, given the size is large. :)
--
Jeff Pang
http://home.arcor.de/pangj/
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/