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}; } }