# Somewhere early on, so that it can be used everywhere. my $error_log; ... # I don't use 'or die' here because I use autodie. open ( $error_log, '>', 'errors.log' ); ... # Later, wherever it's necessary .. print $error_log "$unique_identifier" . "$useful_variables $more useful variables\n";