in reply to Re: true/false condition - what am I doing wrong?
in thread true/false condition - what am I doing wrong?

A common use would be like this:
($today eq 'Monday') ? $firstDay =1 : $firstDay =0;
I have always thought the common use is
$firstDay = $today eq 'Monday' ? 1 : 0;

Replies are listed 'Best First'.
Re^3: true/false condition - what am I doing wrong?
by Marshall (Canon) on Dec 08, 2011 at 16:58 UTC
    correct - tired this morning.. been pulling late nights on a db project...
    main point is that this is not the right place for 'edit' vs 'add'.

    Update: even more uses are possible:

    #!/usr/bin/perl -w use strict; sub is_name_valid { return $_[0]; #just a dummy } print "the name ",is_name_valid(0) ? "was" :"was not"," valid\n"; # the name was not valid print "the name ",is_name_valid(1) ? "was" :"was not"," valid\n"; # the name was valid