#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Location
    santa clara,ca
    Posts
    4
    Rep Power
    0

    Unhappy Perl Newbie: grabbing output of an ext. file


    Hi! I am still new to Perl, and I am having problems saving the output that comes from an external file.

    I currently have a Perl script, which calls and executes an external program and prints the output to the console. I want to "grep" or get the output and store it into an array or variable so that I can use it to put it in a results file.

    The words that the output is printing out is "File" and "Time." I am having trouble because it's not like I am using "printf OUTPUT" and it is going through an output pipe ...the external program just prints the output to console, but I can't edit the external program. Please help!! Thanks!!
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    63
    Rep Power
    15
    Well I am still new at perl too. So I don't know if this will help you or not. If your external file is .txt then below will load whatever is in the text file into an array. Like I said I am with you. I am still new at perl. So if it helped you great cool!

    open (label, "<$Path to external file/blah.txt") || Error ('open', 'file');
    my @arrayname = <label>;

    later
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Location
    santa clara,ca
    Posts
    4
    Rep Power
    0
    Thanks for the help. But that doesn't work. I am executing an external program which displays the results to the console. I want to grep or get the output that the external PROGRAM....and store it into an array or variable. Thanks!!
  6. #4
  7. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    63
    Rep Power
    15
    ummm wow! I totaly miss under stood you! Well I will do a little research and if I find anything I will let you know.

    later
  8. #5
  9. Perl Monkey
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    May 2003
    Location
    the far end of town where the Grickle-grass grows
    Posts
    1,860
    Rep Power
    113
    use backticks (and look in perldoc perlop and go down to "regexp-like quote operators" and look for "qx").

    @lines = `ls`; #backticks ` not single quotes '

    You're not the zao I went to Tennessee Tech with, are you?
  10. #6
  11. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    63
    Rep Power
    15
    @icrf: Sorry that is not me. I never went to Tennessee Tech. Been stuck in fun old Kansas for my hole life.
  12. #7
  13. Perl Monkey
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    May 2003
    Location
    the far end of town where the Grickle-grass grows
    Posts
    1,860
    Rep Power
    113
    I guess, after looking at your profile, he's a couple years older and has a different AIM name. You two probably just share similar taste in music, ie hardcare christian metal.
  14. #8
  15. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    63
    Rep Power
    15
    Yeah must be the same type of music!!!! Zao is awesome!! They are very hardcore and I love it!!! Well I don't know if Zao is really a christian metal band. But I could be wrong. But all I know they are awesome!!!

  16. #9
  17. Perl Monkey
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    May 2003
    Location
    the far end of town where the Grickle-grass grows
    Posts
    1,860
    Rep Power
    113
    Eh, that's jsut what he told me. I think I listened to what he had, and just couldn't get into stuff that hard. I liked three of them, March, Dark Cold Sound, and Desire the End (really liked this last one). Since then, I've stopped listening to so much rock/metal and moved onto electronica/trance. I'm still a huge NIN fan, and would probably still go to Ozzfest again (been twice).

    What was this thread about again (since we hijacked the hell out of it )? Oh yeah, capturing program output. Could also look at open2 and open3 if the backticks/qx wasn't working for you.

    w00t! I broke 800!
    Last edited by icrf; November 6th, 2003 at 03:17 PM.
  18. #10
  19. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    63
    Rep Power
    15
    Yeah I only own one of there albums right now. But that will be changing soon. But I like the buzzing, free the, hree and many others. I always wanted to go to ozzfest but alaways seemed to miss them. But yes back to the "orginal topic" LOL.

IMN logo majestic logo threadwatch logo seochat tools logo