perl inside bash: How to call perl on a script saved in a string
问题 I need to execute the same perl script, multiple times, on different files. To ease the process, I am trying to save the perl script as a bash string, and call perl over the string, as in the "doesn't work" part of the code below: #!/bin/sh # works perl -e 'print 1;' # doesn't work S="'print 1;'" perl -e $S perl -e $S I get the following output: 1Can't find string terminator "'" anywhere before EOF at -e line 1. Can't find string terminator "'" anywhere before EOF at -e line 1. What am I