my $error = $s->error if ($count > 0); ## log this action &log_action('error') if ($count > 0); #### if ($count > 0) { my $error = $s->error; &log_action('error', $error); } #### &log_action('error', $s->error) if ($count > 0); #### sub log_action { my ($action_type, $string) = @_; if (lc($action_type) eq 'error') { print "\n$string\n\n"; print FH "$format $string\n"; ... }