3. Ternary Operator

The ternary operator should not be used as an if-else replacement for calling methods… for example, please do not do this:

$foo ? LJ::do_something() : LJ::do_something_else();

For clarity, please use the following form:

if ($foo) {
} else {

The ternary should be used only in constructions that involve relatively straightforward value substitutions. For example, the following would be fine:

LJ::call_a_function($u, $u->{journaltype} eq 'Y' ? 1 : 0);

Which passes through a 1 if the account is syndicated. It is short and easy to read. Please do not use ternaries in mid-line if you're going to end up with a mess, like this:

LJ::call_another_function($u, $u->{journaltype} eq 'P' && $u->{status} eq 'A' && $u->{statusvis} eq >V> ? ($u->prop('opt_gimmenews') ? 1 : 0) : 0));

Please instead use the following form, breaking it out for readability:

my $is_validated_user = $u->{journaltype} eq 'P' && $u->{status} eq 'A' && $u->{statusvis} eq 'V' ? 1 : 0;
my $wants_news = $is_validated_user && $u->prop('gimmenews') ? 1 : 0;
LJ::call_another_function($u, $wants_news);

Avoid nested ternaries while you're at it.