SQ.pm This Perl/CPAN distribution allows you to write on the command line scripts with $S which expands to a single-quote. perl -lp -MSQ -e 's/$S(\w+)$S/$1/g' Links MetaCPAN https://metacpan.org/release/SQ .