[LA.pm] app_running status...

Peter Benjamin pete at peterbenjamin.com
Wed Nov 1 10:31:02 PST 2006

Such a friendly list this morning.
A reply is called for that explains
the approached used in my first reply.

At 07:41 AM 11/1/2006, Randal L. Schwartz wrote:
>Please don't suggest suboptimal strategies.

The question of using 'system', to me, indicated the poster
was not familiar with perl's ability to invoke commands, and
a complete review of techniques for capturing stdout was a
benefit to not just the poster, but all mungers, so it had
to be included to be comprehensive.

A comprehensive overview (a brief one as perl completely documents
these methods) was, imo, called for, without giving away the
entire algorithm, in order for the poster to have some work
to do themselves.

As far as providing the poster with a single highly optimal
solution, I have to ask why on earth is it necessary to check
if firefox is running?  That is just so odd, that before giving
the 'best' solution, one would have to know the project's criteria,
as it seems a different approach might be more optimal.  So, why
even attempt to suggest an optimal approach in that situation.

As far the most optimal solution, do it in C where there are
OS library functions one can call, instead of invoking perl's
ability to invoke outside processes, which would cut the CPU 
cycles in half for the task.

>>>>>> "Peter" == Peter Benjamin <pete at peterbenjamin.com> writes:
>Peter> Otherwise, pipe it to a temp file.
>There is nothing to be gained, and a lot to be lost, from such a maneuver.

For a beginning perl programmer who needs to see the actual data in
order to fix bugs in the code, having an actual date time stamped
file to view, especially of messy 'ps aux', which can be hundreds of
lines, including other matching lines that should be discarded, like
if someone is grepping 'firefox' at the time the perl runs...

In a lightly loaded computer, there is so little to be lost...
where programmer time has become more valuable than writing
efficient code (something I still can not break my habit for

In some situations such an audit trail method is a firm requirement, 
not necessarily in this situation, so it is a valuable technique.

But most compelling is a subsequent asynchronous process
needing access to the 'identical' snapshot for further processing.

More information about the Losangeles-pm mailing list