m// and s/// are two completely different operators. Do not try to shoehorn them into a single expression like that - you will just be creating less maintainable code. The best solution is not always the one with fewest keystrokes.
if ($some_condition) { ($foo) = ($bar =~ m/capturing_pattern/); else { ($foo = $bar) =~ s/pattern/replacement/; }
That should hopefully be unambiguous and more maintainable than the original proposal.
🦛
In reply to Re^6: surprised to find cannot assign s/../../ to a variable
by hippo
in thread surprised to find cannot assign s/../../ to a variable
by vincentaxhe
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |