You might find File::Rsync or File::RsyncP helpful.
In reply to Re: using STDIN that has no line breaks by ig in thread using STDIN that has no line breaks by macguide