in reply to Embedding perl in bash

Yes, backticks is certainly the most flexible way.
INPUT1="FOO1" INPUT2="FOO2"; RESULT=`perl -E 'for ( @ARGV) { s/FOO/BAR/; say ;}' $INPUT1 $INPUT2`
Output:
$ echo $RESULT BAR1 BAR2