#!/usr/bin/perl use strict; use warnings; our $nan = 'nan' + 0; our $inf = 'inf' + 0; sub tell_me_the_truth{ my $s = shift; my $p = eval $s; local $\ = "\n"; # say if ($p){ print "'$s' ($p) is TRUE." } else{ print "'$s' ($p) is FALSE." } }; tell_me_the_truth('0'); tell_me_the_truth('1'); tell_me_the_truth('0.0'); tell_me_the_truth('$nan'); tell_me_the_truth('$nan == $nan'); tell_me_the_truth('$inf'); tell_me_the_truth('$inf - 1'); tell_me_the_truth('$inf - $inf'); tell_me_the_truth('"0"'); tell_me_the_truth('"0.0"'); tell_me_the_truth('""'); tell_me_the_truth('my @a = ()'); tell_me_the_truth('my %h = ()'); tell_me_the_truth('[]'); tell_me_the_truth('{}'); tell_me_the_truth('undef'); tell_me_the_truth('!!undef'); tell_me_the_truth('!!1');