my $buf = ''; local $/ = \4096; while (<>) { s/\0+//g; $buf .= $_; process_line("$1") while $buf =~ s/^(.*)\n//; } process_line($buf) if length($buf);