If you run it without /e you will notice the string becomes `printhi`. Now you want to eval this expression and the /e takes care of that.
This works for me
#!/usr/bin/perl use strict; use warnings; my $str = "printmeprinthi"; $str =~ s/printme(.*)$/`$1`/e; print $str,$/;
my printhi program is
#!/bin/sh echo hi
output
hi
In reply to Re: Perl inline replace with execution results
by sk
in thread Perl inline replace with execution results
by skerr1
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |