=pod if EXPR unless EXPR given EXPR when EXPR BLOCK default BLOCK (experimental 5.10.1) ========================================================================== if (EXPR) BLOCK if (EXPR) BLOCK else BLOCK if (EXPR) BLOCK elsif (EXPR) BLOCK ... if (EXPR) BLOCK elsif (EXPR) BLOCK ... else BLOCK unless (EXPR) BLOCK unless (EXPR) BLOCK else BLOCK unless (EXPR) BLOCK elsif (EXPR) BLOCK ... unless (EXPR) BLOCK elsif (EXPR) BLOCK ... else BLOCK =cut use feature ":5.10.1"; #exemplul rulează doar de la versiunea PERL 5.10.1 #no warnings; # obligatoriu atunci când se exploatează funcții cu caracter experimental. $string1 = 'acct'; $string2 = 'aCctw'; $comparatie = undef; if ($string1 gt $string2){ say "Sirul $string1 este mai mare decat sirul $string2"; }elsif ($string1 lt $string2){ say "Sirul $string1 este mai mic decat sirul $string2"; }elsif ($string1 eq $string2){ say "Sirul $string1 este identic cu sirul $string2"; }else{ say "Executa orice altceva"; } $comparatie = $string1 cmp $string2; say "Sirul $string1 comparat cu sirul $string2 returneaza: $comparatie"; # Perl gains the experimental keywords: given , when , default , continue, break. # https://perldoc.perl.org/perlsyn.html given ($foo) { when (undef) { say '$foo is undefined'; } when ("foo") { say '$foo is the string "foo"'; } when ([1,3,5,7,9]) { say '$foo is an odd digit'; continue; # Fall through } when ($_ < 100) { say '$foo is numerically less than 100'; } when (\&complicated_check) { say 'a complicated check for $foo is true'; } default { die q(I don't know what to do with $foo); } }