Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Help: Filehandle problem

Reply
Thread Tools

Help: Filehandle problem

 
 
Amy Lee
Guest
Posts: n/a
 
      08-21-2008
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
 
Reply With Quote
 
 
 
 
Tad J McClellan
Guest
Posts: n/a
 
      08-21-2008
Amy Lee <(E-Mail Removed)> 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/"
 
Reply With Quote
 
 
 
 
Jürgen Exner
Guest
Posts: n/a
 
      08-21-2008
Tad J McClellan <(E-Mail Removed)> 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
 
Reply With Quote
 
Sherm Pendley
Guest
Posts: n/a
 
      08-21-2008
Amy Lee <(E-Mail Removed)> 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
 
Reply With Quote
 
Tad J McClellan
Guest
Posts: n/a
 
      08-21-2008
Jürgen Exner <(E-Mail Removed)> wrote:
> Tad J McClellan <(E-Mail Removed)> 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.


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

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
A problem with storing a filehandle as an instance variable Sniff Perl Misc 6 12-21-2007 08:56 PM
Filehandle Pipe Problem? g4173c@motorola.com Perl Misc 2 04-20-2007 04:11 PM
Problem Commenting within Filehandle Iteration Wijaya Edward Python 1 10-26-2006 08:18 AM
Problem using print with a reference to a filehandle niall.macpherson@ntlworld.com Perl Misc 4 06-02-2006 03:43 PM
filehandle to variable problem mathias Perl Misc 3 07-17-2003 12:01 PM



Advertisments