my $errorlog='';
if (...) {
$errorlog.="Oops\n";
}
if (...) {
$errorlog.="Oh noes\n";
}
foo(...);
if (...) {
$errorlog.="Outch\n";
}
if ($errorlog ne '') {
print STDERR $errorlog;
} else {
say 'All done, bye.';
}
####
# We don't need that. It's just wrong: my $errorlog='';
if (...) {
warn 'Oops'; # Oh, by the way: Unless you add "\n", you will see file and line in the log.
}
if (...) {
warn 'Oh noes';
}
foo(...);
if (...) {
warn 'Outch";
}
say "All done, bye.";
##
##
if (...) {
die 'Input data is f*cked up beyond repair. Died to prevent a crash';
}