in reply to Parsing from another program (stream)

It's hard to understand from all this code what your problem is. I'd say open $fh, '-|', $prog should do.

Furthermore you have to read line by line (not "slurp") till you either get the desired EOF or you decide to close the $fh.

But first things first

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^2: Parsing from another program (stream)
by HiredGunTech (Initiate) on Feb 27, 2022 at 21:34 UTC
    LanX -
    yep, 'Print' is 'print'. I pulled it off to format and some MS-auto-corruptor pretty-print capitalized start words.
    (file-not-found) I could quiet that with a chdir, sometimes. - I tried pointing to the full path, that didn't work. The file is there, but various implementations of 'open' throw that. I see a fair number of other folks fighting that. But I think 'open' is the wrong tool anyway.
    As for 'slurp', not the best term, I get it. The issue I have is there will NEVER be an EOF. I am reading gas usage as reported by the meter. And I can't close the file, either.
    So, is there no other way to parse the output of another application as it is presented??
      > But I think open is the wrong tool anyway.

      I used this approach in the past with great success! 🤷🏽

      Maybe try providing an absolute path to the executable.

      edit

      > The issue I have is there will NEVER be an EOF.

      I expect that you get an EOF at least when the process exits or dies. And this case should be covered IMHO.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery