( defined($p) ? '1' . $p : 0 ) eq ( defined($q) ? '1' . $q : 0 )
####
use strict;
use warnings;
my %strings = (
'undef' => undef,
'empty' => '',
'string' => '0'
);
my @pairs = (
[ 'undef' , 'undef' ],
[ 'undef' , 'empty' ],
[ 'undef' , 'string' ],
[ 'empty' , 'empty' ],
[ 'empty' , 'string' ],
[ 'string', 'string' ],
);
for ( @pairs ) {
my ($p,$q) = @strings{@$_};
my $cmp = ( (defined($p) ? '1' . $p : 0)
eq
(defined($q) ? '1' . $q : 0)
) ? 'true' : 'false';
print join(" eq ", @$_), " = $cmp\n";
}
####
undef eq undef = true
undef eq empty = false
undef eq string = false
empty eq empty = true
empty eq string = false
string eq string = true