Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
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


Comment on Re: Perl inline replace with execution results
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://502294]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2014-12-28 07:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (179 votes), past polls