Bootstrap FreeKB - Perl (Scripting) - Getting Started with Booleans
Perl (Scripting) - Getting Started with Booleans

Updated:   |  Perl (Scripting) articles

In Perl, the number 0 is use for the false boolean and any number other than 0 is used for the true boolean.

This script will print false.

#!/usr/bin/perl
use strict;
use warnings;

my $boolean = 0;

if ($boolean) {
  print "true \n";
}
else {
  print "false \n";
}

 

Whereas this script will print true.

#!/usr/bin/perl
use strict;
use warnings;

my $boolean = 1;

if ($boolean) {
  print "true \n";
}
else {
  print "false \n";
}

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 511f6a in the box below so that we can be sure you are a human.