A Quiz about Operator Priorities
#!/usr/bin/perluse 5.36.0;
# ------------------------------------------------
say 'Does priority say we print 2b or ! 2b?';
my($action_types) = qr/PAYMENT|SETTLEMENT|TRANSFER/o;
say "Action types: $action_types";
for my $action (qw/PAYMENT REFUND/)
{
say "Action: $action";
say "Case: 1. $action (1a): ", $action =~ $action_types ? 'Present' : 'Absent';
say "Case: 2. $action (2a): ", "$action (2b): " . $action =~ $action_types ? 'Present' : 'Absent';
say "Case: 3. $action (3a): ", "$action (3b): " . ($action =~ $action_types) ? 'Present' : 'Absent';
say "Case: 4. $action (4a): ", "$action (4b): " . ( ($action =~ $action_types) ? 'Present' : 'Absent');
say "Case: 5. $action (5a): " . ($action =~ /$action_types/ ? 'Present' : 'Absent');
say '';
}
Leave a comment