this({ string => $string, times => 10, }); sub this { my $p = shift; # all params in hashref print $p->{string} x $p->{times}; } #### my $href = { string => "Hello, world!" }; my $previous_error = $error; this($href, $previous_error); sub this { my $p = shift; # all params in hashref my $prev_error = shift; if (not $prev_error){ print $p->{string}; } } #### this(); sub this { my $p = shift; $p->{hostname} = $p->{hostname} || "0.pool.ntp.org"; $p->{port} = $p->{port} || 123; }