From: "HENRY,MARK (HP-Roseville,ex1)" <[EMAIL PROTECTED]>
> 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; }
> ....

No. In both cases you only get anything after the $mycmd finishes.

If you want to read the lines as soon as the other process prints 
them you have to use

        open PIPE, "$mycmd |" or die "Error: $!";
        while ($line = <PIPE>) {
                ...
        }
        close PIPE;

Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery


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

Reply via email to