in reply to Backup filename extension with -i option

[Moved parent from CUFP to SoPW. Perl questions are to be posted in SoPW.]

The command (including $$) is being parsed and interpreted by the shell. If you want Perl to interpret $$, it needs to be in the Perl code. Fortunately, inplace editing (-i) can be initiated from within a script.

perl -pe 'BEGIN { $^I = ".$$" } s/search/replace/g' *.html

Ref: $^I