Help: Filehandle problem

Discussion in 'Perl Misc' started by Amy Lee, Aug 21, 2008.

  1. Amy Lee

    Amy Lee Guest

    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
     
    Amy Lee, Aug 21, 2008
    #1
    1. Advertising

  2. Amy Lee <> 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/"
     
    Tad J McClellan, Aug 21, 2008
    #2
    1. Advertising

  3. Tad J McClellan <> 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
     
    Jürgen Exner, Aug 21, 2008
    #3
  4. Amy Lee <> 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
     
    Sherm Pendley, Aug 21, 2008
    #4
  5. Jürgen Exner <> wrote:
    > Tad J McClellan <> 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/"
     
    Tad J McClellan, Aug 22, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Christopher Reeve
    Replies:
    1
    Views:
    485
    Kevin Goodsell
    Sep 14, 2003
  2. Wijaya Edward
    Replies:
    1
    Views:
    245
    Marc 'BlackJack' Rintsch
    Oct 26, 2006
  3. mathias

    filehandle to variable problem

    mathias, Jul 15, 2003, in forum: Perl Misc
    Replies:
    3
    Views:
    112
    mathias
    Jul 17, 2003
  4. Shmuel (Seymour J.) Metz
    Replies:
    0
    Views:
    351
    Shmuel (Seymour J.) Metz
    May 21, 2006
  5. Amy Lee
    Replies:
    6
    Views:
    127
    Michele Dondi
    Aug 17, 2007
Loading...

Share This Page