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.

...or bundle _all_ parameters into a hashref, which I've found to be
ohhhhh so extensible, with no risk of accidentally using the hash as
part of an array :)

> exiting($hostname, \%login);

exiting({
        hostname => $hostname,
        login    => \%login,
      });

> sub exiting {
>     my $hostname = shift;
>     my %login = %{+shift};
>     ...
> }

sub exiting {
        my $params      = shift;
        my $hostname    = $params->{ hostname };
        my $login       = $params->{ login };

        use Data::Dumper;
        print Dumper $params;
        #...
}

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to