Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Help: Filehandle problem

0 views
Skip to first unread message

Amy Lee

unread,
Aug 21, 2008, 5:23:01 AM8/21/08
to
Hello,

I want to process the output of a program. Anyway, the output is showing
on screen. Is there any way to process it by using file handle? I don't
suppose I should save the output as a file then process this file.

Thank you very much~

Regards,

Amy

Tad J McClellan

unread,
Aug 21, 2008, 6:58:26 AM8/21/08
to
Amy Lee <openlin...@gmail.com> wrote:

> I want to process the output of a program. Anyway, the output is showing
> on screen.


How are you executing the process?

By using Perl's system() function perhaps?

If so, then let me read the docs to you yet again:

perldoc -f system

... This is I<not> what you want to use to capture
the output from a command, for that you should use...


> Is there any way to process it by using file handle?


Yes, though there is an easier way, as above, without using a filehandle.

perldoc -f external

How can I capture STDERR from an external command?

There are three basic ways of running external commands:

system $cmd; # using system()
$output = `$cmd`; # using backticks (``)
open (PIPE, "cmd |"); # using open()


--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"

Jürgen Exner

unread,
Aug 21, 2008, 7:32:02 AM8/21/08
to
Tad J McClellan <ta...@seesig.invalid> wrote:

> perldoc -f external

Tad, you are really getting old :-)

No documentation for perl function 'external' found

> How can I capture STDERR from an external command?

s/-f/-q/

jue

Sherm Pendley

unread,
Aug 21, 2008, 12:12:31 PM8/21/08
to
Amy Lee <openlin...@gmail.com> writes:

> I want to process the output of a program. Anyway, the output is
> showing on screen. Is there any way to process it by using file
> handle?

Have a look at the "Pipe Opens" section in "perldoc perlopentut" for a
much better explanation than I could write here.

sherm--

--
My blog: http://shermspace.blogspot.com
Cocoa programming in Perl: http://camelbones.sourceforge.net

Tad J McClellan

unread,
Aug 21, 2008, 7:44:54 PM8/21/08
to
Jürgen Exner <jurg...@hotmail.com> wrote:
> Tad J McClellan <ta...@seesig.invalid> wrote:
>
>> perldoc -f external
>
> Tad, you are really getting old :-)


Yeah.

Thanks for reminding me.

Maybe I can do the same for you some day.


> No documentation for perl function 'external' found


Ack! I used to copy/paste from the post to ...


>> How can I capture STDERR from an external command?


... get the question. But my terminal puts funny codes in it
so now I grep the indexes of the *.pod files that I made.

Looks like maybe I better start doing both.


> s/-f/-q/


Hey! None of that around here.

This is a family newsgroup.

0 new messages