That actually is OK. <div><br></div><div>In fact, I have more "directions" than just shown. I.e., I have more piping in $cmd than the leading one, and it worked great.<br><br></div><div>cheers</div><div><br><div class="gmail_quote">
On Mon, Dec 6, 2010 at 3:20 PM, J. Bobby Lopez <span dir="ltr"><<a href="mailto:jbl@jbldata.com">jbl@jbldata.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
When you say you got too carried away, I'm guessing the problem was that you were using directions twice?<br><br>One in the $cmd:<br><br> e.g., ' | sed...' <br><br>.. and the other (>>) outside the $cmd:<br>
<br>e.g., open (OUTFILE, "$cmd >> myfile" ) <br><font color="#888888"><br><br><br>Bobby<br><br></font><div class="gmail_quote"><div><div></div><div class="h5">On Mon, Dec 6, 2010 at 11:36 AM, Antonio Sun <span dir="ltr"><<a href="mailto:antoniosun@lavabit.com" target="_blank">antoniosun@lavabit.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex"><div><div></div><div class="h5"><br><div class="gmail_quote"><div>On Mon, Dec 6, 2010 at 10:22 AM, Antonio Sun <span dir="ltr"><<a href="mailto:antoniosun@lavabit.com" target="_blank">antoniosun@lavabit.com</a>></span> wrote:<br>
</div><div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
Hi, <div><br></div><div>I have the following code in a loop:</div><div><br></div><div><div><span style="white-space:pre-wrap">        </span> <span style="white-space:pre-wrap">open(OUTFILE, "$cmd >> myfile"); # append write</span> </div>
<div><span style="white-space:pre-wrap">        </span> print OUTFILE content();</div><div><span style="white-space:pre-wrap">        </span> close(OUTFILE);</div></div><div><div><span style="white-space:pre-wrap"><br>
</span></div><div><span style="white-space:pre-wrap">T</span>he $cmd is a complicated sed command. For simplicity purpose, let's say it is </div><div><br></div><div> | sed -n '10,20p' </div>
<div><br></div><div>I.e., printing only lines 10~20 of the content of each loop. </div><div><br></div><div>My goal is to write to STDOUT instead of a fixed file. I tried to change the above open statement with</div><div>
<br>
</div><div><span style="white-space:pre-wrap">        </span> open(OUTFILE, "$cmd >-"); # write to STDOUT</div></div><div><br></div><div>or,</div><div><br></div><div><div><span style="white-space:pre-wrap">        </span> open(OUTFILE, "$cmd >>-"); # write to STDOUT</div>
</div><div><br></div><div>but didn't get any output. </div></blockquote><div><br></div></div><div>Thank you Richard to have solved my problem. -- I was too carried away with redirections. As you've pointed out, this alone work just as expected:<br>
</div><div><div><br></div><div> <span style="white-space:pre-wrap">        </span> open(OUTFILE, "$cmd"); # write to STDOUT</div><div><br></div></div></div>Thanks<div><br></div>
<br></div></div><div class="im">_______________________________________________<br>
toronto-pm mailing list<br>
<a href="mailto:toronto-pm@pm.org" target="_blank">toronto-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/toronto-pm" target="_blank">http://mail.pm.org/mailman/listinfo/toronto-pm</a><br>
<br></div></blockquote></div><br>
</blockquote></div><br></div>