perl - Odd use of False constant in if-then statement -


python main language, have maintain rather large legacy perl codebase.
have odd logic statement can't make heads or tails over.

at top, constant defined as:

use constant false => 0;  sub thisfunc {      false if ($self->{_thisvar} ne "tif");      ...     ...     return statement,etc.. } 

so i'm reading kinda' fancy, non-standard if-then statement, if $thisvar string not equal "tif", false. huh? not $that = false, false.

the form of statement appears in file several times. codebase in use, , vetted on years team, think valid , has meaning. "use strict;" set @ top.

could kind explain meant logic. i've google'd no joy. in advance,

"if" logic in perl can constructed in couple of ways:

  • the obvious one:

    if ($flag) { do_something() } 
  • less obvious one:

    do_something() if ($flag); 

this example shows how behaves odd "false if" statement - meaning found when last statement in subroutine:

    use strict;      use constant false => 0;      sub thisfunc {         $arg = shift;         false if ($arg ne "tif");     }      print "return val: ".thisfunc("ble")."\n";     print "return val: ".thisfunc("tif")."\n"; 

output running above is:

    return val: 0     return val: 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -