« Apache 2.1 | Main | New job »

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.

Contacts

melo@simplicidade.org (XMPP/email)
+351 302 029 050 (voice)
melopt (Skype)

IronMan challenge

Iron Man badge Are you ready to be an Iron Man? Join the challenge and find out! (what is the meaning of this little man?)

Moosaico

Junta-te!

Recent Comments

Powered by Disqus
Creative Commons License
This weblog is licensed under a Creative Commons License.
Powered by
Movable Type 3.2