in reply to Re: Can this If/Else be condensed into a 1 liner with a trailing If?
in thread Can this If/Else be condensed into a 1 liner with a trailing If?

Hi,

I personally love using the conditional operator. You just have to be careful with it. For example:

#! /usr/local/bin/perl -w use strict; $a = 1; $b = 2; (1) ? $a = 3 : $b = 4; print "1) a = $a, b = $b\n"; (1) ? ($a = 3) : ($b = 4); print "2) a = $a, b = $b\n";
displays:
1) a = 4, b = 2 2) a = 3, b = 2
Which may or may not be what you expect.

Good luck!
{NULE} PS I'm having issues with Opera again, please forgive me if I screw this post up (again.) Time for a new web-browser *sigh*.