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><br><br><br>Bobby<br><br><div class="gmail_quote">On Mon, Dec 6, 2010 at 11:36 AM, Antonio Sun <span dir="ltr"><<a href="mailto:antoniosun@lavabit.com">antoniosun@lavabit.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><br><div class="gmail_quote"><div class="im">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 class="im"><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 class="im"><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>_______________________________________________<br>
toronto-pm mailing list<br>
<a href="mailto:toronto-pm@pm.org">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></blockquote></div><br>