C
compuman
Hi
How do avoid the delay when capturing output from a shell command in
Perl?
For example, consider the following example using a find command in a
home directory:
foreach (`find /home/user -type f -print`)
{
print "$_";
}
If I had run the find command on the command line I would see the
output would appear immediately. However putting it into a perl script
like this causes a delay.
I'm guessing that this is because the command is executed first and
then each line is processed by the foreach loop.
However, I want to see the output immediately, just as if I had run
this on the command line.
Any ideas how to achieve this?
How do avoid the delay when capturing output from a shell command in
Perl?
For example, consider the following example using a find command in a
home directory:
foreach (`find /home/user -type f -print`)
{
print "$_";
}
If I had run the find command on the command line I would see the
output would appear immediately. However putting it into a perl script
like this causes a delay.
I'm guessing that this is because the command is executed first and
then each line is processed by the foreach loop.
However, I want to see the output immediately, just as if I had run
this on the command line.
Any ideas how to achieve this?