in reply to Re^4: hang caused by read / readline?
in thread hang caused by read / readline?

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

Replies are listed 'Best First'.
Re^6: hang caused by read / readline?
by grepdashv (Initiate) on Sep 04, 2009 at 18:53 UTC
    Thanks! I was able to get some Chatterbox help, also. I noticed that your first example used a chunk size of 65536, but this example is using a chunk size of 4096. I used 65536 in my script, and it ran very quickly. Is there a reason to use something other than 65536 for $/ ? What are the considerations?

      Benchmark to see what works best for your data. I made up both numbers. (Perl does 4k reads internally.)

        Thanks to you (and to the Chatterbox users) for your help!