You've got a buffering problem. One option would be to set $/ to a reference to an integer, which will cause perl to give you a chunk of that many bytes on each read, rather than reading a line at a time. If you do this though, you then have to deal with assembling the records into lines yourself. Something like this should work...
open ( CORE, "/usr/bin/rsync $rsyncOPT --progress $outbox $inbox |" ); local $/ = \128; # read 128 bytes at a time my $buffer = ''; while( <CORE> ) { $buffer .= $_; while ( $buffer =~ s/^(.*?)[\r\n]// ) { local $_ = $1; # code } }
Another (possibly better) option would be to use Expect, which is designed for this type of application...
| We're not surrounded, we're in a target-rich environment! |
|---|
In reply to Re: parsing rsync output
by jasonk
in thread parsing rsync output
by eddor1614
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |