<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jan 9, 2010, at 12:52 PM, Antonio Sun wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Hi, <br><br>Here is the simplified example of what I want to do:<br><br> DB<1> $v = 'AAabcDDabc'<br> DB<2> $v = m/abc/`echo $& | rev`/g<br>Backticks found where operator expected . . . <br><br>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.<br></blockquote><div><br></div><div>f you really want to do it that way then you can use s///ge for example:</div><div><br></div><div><div> DB<1> sub rev_chomp { my $v = `echo $_[0] | rev`; chomp $v; $v }</div><div><br></div><div> DB<2> x rev_chomp 'foo'</div><div>0 'oof'</div><div> DB<3> $v = 'AAabcDDabc'</div><div><br></div><div> DB<4> $v =~ s/(abc)/rev_chomp($1)/ge</div><div><br></div><div> DB<5> x $v</div><div>0 'AAcbaDDcba'</div><div><br></div><div>Hope this helps,</div><div><br></div><div>Mike</div></div></div><br><div>
<span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">-- </div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br class="khtml-block-placeholder"></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Mike Stok <<a href="mailto:mike@stok.ca">mike@stok.ca</a>></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><a href="http://www.stok.ca/~mike/">http://www.stok.ca/~mike/</a></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br class="khtml-block-placeholder"></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">The "`Stok' disclaimers" apply.</div><div><br class="khtml-block-placeholder"></div><div><br class="khtml-block-placeholder"></div><br class="Apple-interchange-newline"></span>
</div>
<br></body></html>