Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Perl inline replace with execution results

by sk (Curate)
on Oct 23, 2005 at 05:39 UTC ( #502294=note: print w/replies, xml ) Need Help??


in reply to Perl inline replace with execution results

Remove the \ before $1 and you need /e

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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://502294]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2016-12-04 00:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (61 votes). Check out past polls.