Created
January 22, 2019 17:47
-
-
Save wolfsage/5527f3f4ef7610c168c0d5fe02b9b24d to your computer and use it in GitHub Desktop.
unless.pl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mhorsfall@tworivers:~$ cat unless.pl | |
use strict; | |
use warnings; | |
my @strs = ( | |
'$x = do { unless ("cat" eq "cat") { } };', | |
'$x = do { unless ("cat" ne "cat") { } };', | |
'$x = do { if ("cat" eq "cat") { } };', | |
'$x = do { if ("cat" ne "cat") { } };', | |
); | |
for my $str (@strs) { | |
my $x; | |
eval $str; die "Failed $@\n" if $@; | |
$x ||= 0; | |
print "$str: $x\n"; | |
} | |
mhorsfall@tworivers:~$ perl unless.pl | |
$x = do { unless ("cat" eq "cat") { } };: 1 | |
$x = do { unless ("cat" ne "cat") { } };: 0 | |
$x = do { if ("cat" eq "cat") { } };: 0 | |
$x = do { if ("cat" ne "cat") { } };: 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment