[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] TMTOWTDI



> #    1) write the returned data to a file, open it, and loop through the lines

Probably wouldn't do this, as it has the overhead of opening a
file and reading it in addition to running the command. I also
don't like to have to clean up after I run an external command 
if I can avoid it. And there is the issue of what to name the 
file (something with pid probably) and where to put it.

> #    2) do an open with a pipe when you call the external command and attach
> #       the data to the filehandle, then iterate over <HANDLE>

This is what I usually do. It gives you the lattitude to display
the output as it runs (without the tee command) if you desire.
Also avoids the overhead of the split in the third example.

However, if you are encapsulating this code into a subroutine that
returns an list (or a reference to an list) of the output, the
thrid option might be a little better. It avoids the need to push
the output onto a list during the while loop of the second example.

My goal would be the most maintainable code, so in light of that I 
would end up with something like 2 or 3 depending on specific 
circumstances.

Kevin

-- 
------------------------------------------------------------
 keViN cUReToN - ProDuCtiOn EnGiNeEr - SoFtWArE DeVElOpmEnT
  (650)846-8388       kevinc@pdi.com    http://www.pdi.com
  <<- Madness takes its toll, please have exact change ->>

==== Want to unsubscribe from Fun With Perl?
==== Well, if you insist... Send mail with body "unsubscribe" to
==== fwp-request@technofile.org