I had need for a new #perl operator today, like:

$val //~ s/$prefix//;

that would be equivalent to:

$val =~ s/$prefix// if defined $val;

is it too late to get this for v5.42 ?

#notdeadyet #morelinenoise @Perl

@Pyrrhlin @Perl How about this instead of the postfix `if`?

defined $val and $val =~ s/$prefix//;

@mjgardner @Perl also good. #timtowdi my friend!
why do i prefer postfix `if`? hmm.
maybe the conditional `and` with a statement (rather than a test) feels like `map` in void context, which also feels a little icky

@Pyrrhlin I do it all the time for cheap regexp-based switches, as described in perlfaq7: https://perldoc.perl.org/perlfaq7#How-do-I-create-a-switch-or-case-statement?

```
SWITCH: for ($pizza) {
/pepperoni/ and do {say 'yum!'; last SWITCH};
/anchovies/ and do {say 'yuck!'; last SWITCH};
}
```

perlfaq7 - General Perl Language Issues - Perldoc Browser

@mjgardner sure. I use the low-precedence boolean ops in some conditional test where i also want/need to set/topicalize a lexical var.
for your switch construct, i'd use the trailing `if` again :)

@Pyrrhlin I like to see the test first when reading from left to right.

Per #perlcritic I reserve postfix controls for program flow control functions like return, last, next, etc. https://metacpan.org/pod/Perl::Critic::Policy::ControlStructures::ProhibitPostfixControls

Perl::Critic::Policy::ControlStructures::ProhibitPostfixControls

Write if($condition){ do_something() } instead of do_something() if $condition.

MetaCPAN