That looks like a sensible approach. If you have a perl released in the last decade and a half you can use defined-or to shorten the syntax too:
use 5.010; my $pattern = $options{pattern} // $default_pattern; my $replacement = $options{replacement} // $default_replacement; $text =~ s/$pattern/$replacement/;
🦛
In reply to Re^4: 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: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |