<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>&nbsp; DB&lt;1&gt; $v = 'AAabcDDabc'<br>&nbsp; DB&lt;2&gt; $v = m/abc/`echo $&amp; | 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>&nbsp;&nbsp;DB&lt;1&gt; sub rev_chomp { my $v = `echo $_[0] | rev`; chomp $v; $v }</div><div><br></div><div>&nbsp;&nbsp;DB&lt;2&gt; x rev_chomp 'foo'</div><div>0 &nbsp;'oof'</div><div>&nbsp;&nbsp;DB&lt;3&gt; $v = 'AAabcDDabc'</div><div><br></div><div>&nbsp;&nbsp;DB&lt;4&gt; $v =~ s/(abc)/rev_chomp($1)/ge</div><div><br></div><div>&nbsp;&nbsp;DB&lt;5&gt; x $v</div><div>0 &nbsp;'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; ">--&nbsp;</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 &lt;<a href="mailto:mike@stok.ca">mike@stok.ca</a>&gt;</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>