Skip to content

Instantly share code, notes, and snippets.

@wolfsage
Created January 22, 2019 17:47
Show Gist options
  • Save wolfsage/5527f3f4ef7610c168c0d5fe02b9b24d to your computer and use it in GitHub Desktop.
Save wolfsage/5527f3f4ef7610c168c0d5fe02b9b24d to your computer and use it in GitHub Desktop.
unless.pl
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