open ( CORE, "/usr/bin/rsync $rsyncOPT --progress $outbox $inbox |" ); local $/ = \128; # read 128 bytes at a time my $buffer = ''; while( ) { $buffer .= $_; while ( $buffer =~ s/^(.*?)[\r\n]// ) { local $_ = $1; # code } }