in reply to Warning while using ternary operator

If what you really want is:

Then one way to achieve this is:

($i eq 'one') ? $hash->{'name'} = "hello"."world" : 0;

Executing "0" does not give a warning, unlike executing 'nothing'.

Replies are listed 'Best First'.
Re^2: Warning while using ternary operator
by tobyink (Canon) on Dec 17, 2013 at 11:51 UTC

    Though that would be a hell of a lot more readable as:

    $hash->{'name'} = "hello"."world" if $i eq 'one';
    use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name