#!/usr/bin/perl
use strict;
use warnings;
use 5.010;
{
my $true = !! 1;
my $false = !! 0;
my $result = $true ? "first" : "second";
say $result;
}
{
my $size = 15;
my $result =
($size < 10) ? "small" :
($size < 20) ? "medium" :
($size < 30) ? "large" : "extra-large";
say $result;
}
{
my $u1 = undef;
my $r1 = $u1 || "default";
say $r1;
my $u2 = undef;
my $r2 = defined $u1 ? "defined" : "undefined";
say $r2;
}
{
my $u1 = undef;
my $r1 = $u1 // "default";
say $r1;
my $u2 = "defined";
my $r2 = $u2 // "default";
say $r2;
}
{
my $m = 20;
my $n = 10;
($m < $n) && ($m = $n);
say "$m:$n";
$m = 10;
$n = 20;
($m < $n) && ($m = $n);
say "$m:$n";
($m < 10) || say "Hello";
my $true = !! 1;
my $false = !! 0;
$false || say "false";
$true && say "true";
$false or say "die";
$true and say "die";
}
exit;