mephtu has asked for the wisdom of the Perl Monks concerning the following question:

This prints "Running.": perl -e '%s = ( "RUNNING" => false ); if ($s{"RUNNING"}) { print "Running." }' Wow. Help? --mephtu

Replies are listed 'Best First'.
Re: Using hash value as condition.
by graff (Chancellor) on Mar 30, 2014 at 00:57 UTC
    The point here is that "false" is not a reserved word (or a built-in function) in Perl, so it has no special meaning. In your snippet, it's treated as a "bareword", which you can look up under "B" in the perlglossary:

    A word sufficiently ambiguous to be deemed illegal under use strict 'subs'. In the absence of that stricture, a bareword is treated as if quotes were around it.

    In other words:

    perl -le '$x = false; print length($x); print "x is ".join("-",split// +,$x)'
    (that will print out two lines: "5" and "x is f-a-l-s-e")
Re: Using hash value as condition.
by hippo (Archbishop) on Mar 29, 2014 at 23:10 UTC

    Not using strict and not using warnings. Either would have hinted at the reason.

Re: Using hash value as condition.
by AnomalousMonk (Archbishop) on Mar 30, 2014 at 04:11 UTC
Re: Using hash value as condition.
by NetWallah (Canon) on Mar 30, 2014 at 01:43 UTC
    Another way to say it:
    perl -E 'say "false is " , "false" ? "TRUE" :"FALSE"' false is TRUE

            What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?
                  -Larry Wall, 1992

Re: Using hash value as condition.
by 7stud (Deacon) on Mar 29, 2014 at 23:37 UTC
    ...or what is this false thing in your code?
Re: Using hash value as condition.
by mephtu (Novice) on Apr 02, 2014 at 23:01 UTC
    Many thanks. Perhaps now I can get some sleep.