How to use boolean variables (true and false) in Perl

I was quite disappointed when I realized, that boolean variables (true and false) are not allowed in Perl. I figured out a workaround which is quite pretty useful.

use constant {
  false => 0,
  true => 1

Use it:

$myVariable = true;

if ( $myVariable == true ) {
  # stuff


Yesterday we've released our Golden Ratio Calculator for Android at Google Play:

Syndicate content