[tpm] Replace a string with the result of shell command

Indy Singh indy at indigostar.com
Sat Jan 9 10:27:13 PST 2010


This might be closer to what you want:
$v = 'AAabcDDabc';
$v =~ s/abc/`echo $& | rev`/eg;

Note: 
Replace '=' with '=~'
Replace 'm' with 's'
Use the /e operator

Indy Singh
IndigoSTAR Software -- www.indigostar.com

  ----- Original Message ----- 
  From: Antonio Sun 
  To: TPM Mongers 
  Sent: Saturday, January 09, 2010 12:52 PM
  Subject: [tpm] Replace a string with the result of shell command


  Hi, 

      Here is the simplified example of what I want to do:

    DB<1> $v = 'AAabcDDabc'
    DB<2> $v = m/abc/`echo $& | rev`/g
  Backticks found where operator expected . . . 

  Please don't take it literally, and argue that shell invoking is not necessary -- I want to replace a certain string with the result of shell command, and pass the matched string to the shell command as well.

  Please help.
  Thanks

  Antonio




------------------------------------------------------------------------------


  _______________________________________________
  toronto-pm mailing list
  toronto-pm at pm.org
  http://mail.pm.org/mailman/listinfo/toronto-pm
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/toronto-pm/attachments/20100109/664e430e/attachment.html>


More information about the toronto-pm mailing list