sub execute { my $error = $s->$error if ($count > 0); ## log this action &log_action($error) if ($count > 0); # just pass the $error var to &log_action } sub log_action { my $i = shift; if ($i) { print "\n$i\n\n"; print FH "$format $error"; } }