You were being way too cute in being too brief and not describing what
you are thinking.
perl
-w warnings
-l enables automatic line-ending processing: chomp() and set $\
-p autoprint the result
-e the program is the next argument
s[\w]: it took me a moment to realize that you're expecting it to
cause an error about a bad s///, but it works as a substitute.
$ perl -wlpe 's[\w]; FROG FROG'
s3333
FROG FROG
3333
But it works only with ;. Aha!
$ perl -wlpe 's[\w]! FROG FROG'
Backslash found where operator expected at -e line 2, near
";}continue{print or die qq(-p destination: $!\"
(Missing operator before \?)
Unquoted string "n" may clash with future reserved word at -e
line 2.
Final $ should be \$ or $name at -e line 1, within string
syntax error at -e line 2, near ";}continue{print or die qq(-p
destination: $!"
(Might be a runaway multi-line !! string starting on line 1)
Execution of -e aborted due to compilation errors.
Apparently, where "man perlrun" says
-p causes Perl to assume the following loop around your program, which
makes it iterate over filename arguments somewhat like sed:
LINE:
while (<>) {
... # your program goes here
} continue {
print or die "-p destination: $!\n";
}
it doesn't mean "it'll be treated like that", it means "it bloody well
IS wrapped in that, in a very real and literal sense". Similarly
$ perl -wlpe 's[\w]{ FROG FROG'
Having no space between pattern and following word is deprecated at -e
line 2.
Use of /c modifier is meaningless in s/// at -e line 2.
Bareword found where operator expected at -e line 2, near ";}continue"
(Might be a runaway multi-line {} string starting on line 1)
(Missing operator before ntinue?)
syntax error at -e line 2, near ";}continue"
Missing right curly or square bracket at -e line 2, at end of line
Execution of -e aborted due to compilation errors.
Is there any way to fix this in general? That is, is there any way to
have an arbitrary set of Perl code and interpolate it into a code
skeleton where the interpolation can't break the skeleton somehow?