But if want to use all things: a /e modifier, html tags and # instead of / (because \-escaped slashes are not very readable)$bar =~ s/(\d{2})/joo/msg; $bar =~ s#(\d{2})#jee#msg; $bar =~ s#(\d{2})#foo($1)#mesg; $bar =~ s#(\d{2})#<td>ha ha ha</td>#msg;
man perlop is not very helpful.Bareword found where operator expected at a.pl line 18, near "<td>foo" (Missing operator before foo?) syntax error at a.pl line 18, near "<td>foo" Search pattern not terminated at a.pl line 18.
Any non-whitespace delimiter may replace the slashes. Add space after the "s" when using a character allowed in identifiers. If single quotes are used, no interpretation is done on the replacement string (the "/e" modifier overrides this, however). Note that Perl treats backticks as normal delimiters; the replacement text is not evaluated as a command. If the PATTERN is delimited by bracketing quotes, the REPLACEMENT has its own pair of quotes, which may or may not be bracketing quotes, for example, s(foo)(bar) or s<foo>/bar/. A /e will cause the replacement portion to be treated as a full-fledged Perl expression and evaluated right then and there. It is, however, syntax checked at compile-time. A second "e" modifier will cause the replacement portion to be "eval"ed before being run as a Perl expression.Tested in Debian Jessie (5.20) and in Debian Buster (5.29).
In reply to Side effects of an /e modifier by timpoiko
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |