<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.18975">
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT size=2 face=Arial>Tell us the 'more complicated sed command'.
We might be able to come with a reg expression that would give you equivalent in
pure perl.</FONT></DIV>
<DIV><FONT size=2 face=Arial>Something like this:</FONT></DIV>
<DIV><FONT size=2 face=Arial>$x = content();</FONT></DIV>
<DIV><FONT size=2 face=Arial>$x =~ s/some_reg_ex/;</FONT></DIV>
<DIV><FONT size=2 face=Arial>print $x;</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>Since some us are not sed experts just also explain
in words (or pseudo-perl) what you want the command to do.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV>Indy Singh<BR>IndigoSTAR Software -- <A
href="http://www.indigostar.com">www.indigostar.com</A><BR></DIV>
<BLOCKQUOTE
style="BORDER-LEFT: #000000 2px solid; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="FONT: 10pt arial; BACKGROUND: #e4e4e4; font-color: black"><B>From:</B>
<A title=antoniosun@lavabit.com href="mailto:antoniosun@lavabit.com">Antonio
Sun</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=tpm@to.pm.org
href="mailto:tpm@to.pm.org">TPM Mongers</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Monday, December 06, 2010 10:22
AM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> [tpm] Writing to STDOUT in
batches</DIV>
<DIV><BR></DIV>Hi,
<DIV><BR></DIV>
<DIV>I have the following code in a loop:</DIV>
<DIV><BR></DIV>
<DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>
<SPAN style="WHITE-SPACE: pre" class=Apple-style-span>open(OUTFILE,
"$cmd >> myfile"); # append write</SPAN> </DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>
print OUTFILE content();</DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>
close(OUTFILE);</DIV></DIV>
<DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span><BR></SPAN></DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span>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" class=Apple-tab-span></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" class=Apple-tab-span></SPAN>
open(OUTFILE, "$cmd >>-"); # write to STDOUT</DIV></DIV>
<DIV><BR></DIV>
<DIV>but didn't get any output. </DIV>
<DIV><BR></DIV>
<DIV>Anyone can help me here? </DIV>
<DIV><BR></DIV>
<DIV>BTW, in case you wonder why the open statement is in the loop -- if
I don't do it this way and open outside the loop instead, I'll get the
first 10~20 lines only from the first loop.</DIV>
<DIV><BR></DIV>
<DIV>Thanks</DIV>
<DIV><BR></DIV>
<DIV>antonio</DIV>
<DIV><BR></DIV>
<DIV><BR></DIV>
<P>
<HR>
<P></P>_______________________________________________<BR>toronto-pm mailing
list<BR>toronto-pm@pm.org<BR>http://mail.pm.org/mailman/listinfo/toronto-pm<BR></BLOCKQUOTE></BODY></HTML>