in reply to parentheses around a function call in a ternary choice

In addition to moritz's comments, you can fix your example by using
... print +(get1()) ? "3: Flag is up\n" : "3: Flag is not up\n"; print +(&get1 ) ? "4: Flag is up\n" : "4: Flag is not up\n"

which causes the output to change to...

... 3: Flag is up 4: Flag is up


Unless I state otherwise, all my code runs with strict and warnings

Replies are listed 'Best First'.
Re^2: parentheses around a function call in a ternary choice
by didess (Sexton) on Jun 23, 2009 at 21:20 UTC
    To be very honest, the warnings coming when using "warnings"

    do not explain very much to me !

    (which constants are we warned about ?)

    But your explanations do explain all clearly!

    Thanks to all

      a successful print returns true (see print). So your prints are equivalent to

      1 ? "3: Flag is up\n" : "3: Flag is not up\n";

      and that's a constant expression that evaluates to

      "3: Flag is up\n";

      That's a constant that isn't used for anything -- a constant in void context.

      When you get errors or warnings you don't understand try adding use diagnostics;. It will try to explain the error or warning given.


      Unless I state otherwise, all my code runs with strict and warnings