mhearse has asked for the wisdom of the Perl Monks concerning the following question:
Rather than block for the output, I would like to start the command and spool the output to an array. Simultaneously, I would then parse the output if certain conditions exist (system load, time of day). How could I do this? Could fork be used?open CMD, "/usr/local/bin/inotifywait |"; while (my $output = <CMD>) { ....... }
Then somewhere else...my @output; while (my $line = <CMD>) { chomp $line; push @output, $line; }
for my $out (@output) { if (condition exists) { parse output; } ..... }
|
|---|