3. Return early when possible

Nested control constructures with huge bodies are bad enough, but it's particularly unnecessary to scroll down past multiple pages of code only to find:

          }
        }
     }
   } else {
      return 0;
   }

At that point, who really knows what that return 0 is for? Yes, put your cursor on a brace and Emacs and will happily show you, but there is a better approach. Using the approach below also helps to avoid adding extra indentation.

So, instead of this:

if ($good) {
     …code…
} else {
    return 0;
}

Please do this:

return 0 unless $good;
…code…