1 2 3 4 5 6 7 8
for my $x ( 1,2,3,4,6,8,12,13,14,42,43,134,143 ) { if ( $x =~ m{\A (?: 4?3 | 1?4 ) \z}x ) { print "$x: Plan A"; } else { print "$x: Plan B"; } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14
my $vergleich = 4; my @a = (3,4,14,43); my $isin = 0; foreach my $elem (@a) { if ($vergleich == $elem) { $isin = 1; last; } } if ($isin) { ... mache planA ... } else { ... mache planB ... }
1 2 3 4 5 6 7 8 9 10
my $vergleich = 4; my @a = (3,4,14,43); #if ( grep { $vergleich == $_ } @a ) { if ( first { $vergleich == $_ } @a ) { # ... plan A } else { # ... plan B }
1
2
3
use Quantum::Superpositions;
$vergleich = 4;
if ($vergleich == any(3,4,14,43)) { ist drin }