$ cat >mytool.pl #!/usr/bin/perl print 'Substitute string'; $ chmod 755 mytool.pl $ cat >test.tmpl This is mytool.pl foo $ perl -pe's/(mytool\.pl\b.*)/`.\/$1`/e' test.tmpl This is Substitute string $