Building simplicidade.org: notes, projects, and occasional rants

It depends

When writing Perl, should you use this:

  if (!unlink($file)) {
   $log_main->warn("Could not delete temp file '$file'");
 }

or this?

$log_main->warn(“Could not delete temp file ‘$file’”) unless unlink($file);

The second one is shorter, and has extra-geek-points, but I say that “it depends”.

In this case I settled on the first form because the important part, the important action, is the unlink() call. You should always put the important action first.