Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: capturing command output

by Ratazong (Prior)
on Jan 25, 2012 at 10:21 UTC ( #949866=note: print w/ replies, xml ) Need Help??


in reply to capturing command output

Two aspects you might want to consider

  • writing to a temporary output file (as done in your example) might lead to troubles with write-access-rights
  • writing to a temporary output file is helpful when debugging, as that file can be checked easily afterwards outside of perl (unless you delete it)
In my projects, I have no real preference. I typically decide it case-base-case based on the "feeled risk of needing debugging info"

HTH, Rata

Update: Oooops! I have overlooked the pipe-symbol. So please ignore my answer above! Thanks for pointing this out, BrowserUk!


Comment on Re: capturing command output
Re^2: capturing command output
by BrowserUk (Pope) on Jan 25, 2012 at 10:23 UTC

    The code is not writing to a temporary file. The external process is writing directly to a pipe which is then read in the while loop.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://949866]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (10)
As of 2014-09-16 11:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (13 votes), past polls