Author image Robert Rothenberg
and 1 contributors


Logic::Kleene - Kleene three-valued logic


  use Logic::Kleene;

  $a = !kleene( somefunction() );

  if ($a && $b) { ... } 


This module implements Kleene three-valued logic via overloading.

The third value is between true and false, and is equivalent to an undefined value (as when a program has not yet returned a value).

The significant different is that the negation of an undefined value is still undefined (and so treated as false). For example,

  my $status = kleene(somefunction());
  if (!$status) {
    print "somefunction failed";

If the status value is false, then it will print the failure message, as expected. But if the status is undefined, then it will not print the message.

It is important to note that


is not equivalent to


since in the first case, $x may not be a Kleene value.


Robert Rothenberg <rrwo at>

Suggestions and Bug Reporting

Feedback is always welcome. Please use the CPAN Request Tracker at to submit bug reports.


Copyright (c) 2005 Robert Rothenberg. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.