[tpm] Writing to STDOUT in batches

J. Bobby Lopez jbl at jbldata.com
Mon Dec 6 12:20:55 PST 2010


When you say you got too carried away, I'm guessing the problem was that you
were using directions twice?

One in the $cmd:

  e.g.,  ' | sed...'

.. and the other (>>) outside  the $cmd:

e.g.,  open (OUTFILE, "$cmd >> myfile" )



Bobby

On Mon, Dec 6, 2010 at 11:36 AM, Antonio Sun <antoniosun at lavabit.com> wrote:

>
> On Mon, Dec 6, 2010 at 10:22 AM, Antonio Sun <antoniosun at lavabit.com>wrote:
>
>> Hi,
>>
>> I have the following code in a loop:
>>
>>     open(OUTFILE, "$cmd >> myfile"); # append write
>>     print OUTFILE content();
>>     close(OUTFILE);
>>
>> The $cmd is a complicated sed command. For simplicity purpose, let's say
>> it is
>>
>>   | sed -n '10,20p'
>>
>> I.e., printing only lines 10~20 of the content of each loop.
>>
>> My goal is to write to STDOUT instead of a fixed file. I tried to change
>> the above open statement with
>>
>>     open(OUTFILE, "$cmd >-");   # write to STDOUT
>>
>> or,
>>
>>     open(OUTFILE, "$cmd >>-");   # write to STDOUT
>>
>> but didn't get any output.
>>
>
> 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:
>
>      open(OUTFILE, "$cmd");   # write to STDOUT
>
> Thanks
>
>
> _______________________________________________
> toronto-pm mailing list
> toronto-pm at pm.org
> http://mail.pm.org/mailman/listinfo/toronto-pm
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/toronto-pm/attachments/20101206/b8e4ce72/attachment.html>


More information about the toronto-pm mailing list