in reply to passing a variable from one subroutine to another

The name exec is poorly chosen for a perl sub. See perldoc -f exec.

The preferred way of passing an error value along is to do so directly:

#from 'exec' sub &log_action($error) if ($count > 0); # ... #later... sub log_action { my $error = shift; print "\n$error\n\n" && # next print FH is fishy. When is FH opened and closed? print FH "$format $error" if $error; }
It is bad design to use globals or widely scoped lexicals to pass values to subs.

After Compline,
Zaxo