Mark Henry wrote:
> 
> Hi All,

Hello,

> Wondering if someone has feedback on this..
> 
> When using backticks to capture the output of an external command, one can
> scan each line as it happens, or dump the output into an array and then go
> back and take a look.
> 
> foreach $line (`$mycmd`) {
> if ($line=~/[Ee]rror) { last; }
> ....
> 
> vs.
> 
> @cmdoutput=`$mycmd`;
> foreach $line (@cmdoutput) {
> if ($line=~/[Ee]rror) { last; }
> ....
> 
> I'm wondering if the 'last' statement into the first example above, will
> affect, or strand perhaps, the process I started by the backticks? last
> would effectively cease attempts to read data from the command, but the
> command hasn't terminated gracefully at this non-completed stage, and in
> this case is it just abandoned?  Or will perl clean up after me?

foreach will store the output of the command in a list and then iterate
over that list.  The command has ended by the time the first statement
in the loop is encountered.


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to