in reply to Parsing a file line by line until a certain indice in array

I only want it to return the line with john in it.
If you mean that you only want your program to print to STDOUT the line with 'john' in it, then you should not use print everywhere except in your 'got got' line.

If you mean something else, please clarify. It would help if you show us an example of the exact output you expect, inside 'code' tags.

See also: How do I compose an effective node title?

  • Comment on Re: Parsing a file line by line until a certain indice in array

Replies are listed 'Best First'.
Re^2: Parsing a file line by line until a certain indice in array
by sluggo (Novice) on Sep 05, 2009 at 18:47 UTC
    Hello toolic,

    Thank you very much for taking the time to reply. I am sorry about the lack of clarity in my post (first time hehe). Also, sorry for the massive prints, I was using them to see which parts of the code were actually executing.

    Yes you are correct, I would like to print to STDOUT just the line with john in it.

    The exact output I expect is:

    root# perl ult_test.pl -v john -h file1.txt john got got

    Really all I'm looking for is john got got, the others just let me know the other sections were run. I ran into trouble with having the subroutine 'pars0r' print the else statement for every element/line in the list/array when all I want is the line that contains john

    Thank you very much for your time. If I am still unclear at all, please let me know and I will do my best to convey better.

    Sluggo