Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
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 exploiting the Monastery: (3)
As of 2014-07-14 01:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (253 votes), past polls