http://qs321.pair.com?node_id=1106933


in reply to Why so strict?

What you're employing is the Ternary operator which has the form:

$variable = <condition> ? <value1> : <value2>;

The variable gets set to value1 if the condition resolves to true, or value2 if the condition resolves to false. So you should not be using "say" in either the value1 or value2 positions as you do in your example. So lets rewrite it without the say:

my $c = <true/false> ? "$c found!" : "None!";

And now the problem is clear, in the true case, you're trying to initialize $c to a value that contains _itself_. It's like saying my $c = $c, it's nonsensical.

Replies are listed 'Best First'.
Re^2: Why so strict?
by mikeh123 (Novice) on Nov 12, 2014 at 03:38 UTC
    Thanks to both of you for the clarity! For far too long I've thought of the ternary operator as, well, not an operator, but a concise shorthand for if/else. Perfectly and quickly answered; thanks for sharing the wisdom!