in reply to Re: Using join and ternary operator together
in thread Using join and ternary operator together

Just a pet peeve for the most part, but I prefer using parens even when they are not strictly needed just to improve clarity of intent. Seems to help me, anyway.

my $stmt = join(" ", "select * from dbo.server" , (defined($orderby) ? + "order by $orderby;" : ";"));

On a side note, I presume you have a space in front of the word "order" in your true clause. I.e. " order by $orderby;" or else you would wind up with SQL that read something like this: select * from dbo.serverorder by .... That would clearly be wrong.

Replies are listed 'Best First'.
Re^3: Using join and ternary operator together
by AnomalousMonk (Archbishop) on Sep 11, 2013 at 04:04 UTC
    ... a space in front of the word "order" in your true clause.

    That space would be supplied by the  " " join string of the join function.

      Good catch, I should know better than to try catching stuff like when I'm that tired. I thought that was too obvious. :)