Regarding MCE, MCE::Flow, and friends, the chunk_size option is dual mode. A value greater than 8192 means to read n_bytes and till the end of line. A value lower or equal to 8192 reads number of lines. I used the word lines to indicate the default $/ = "\n" or RS => "\n".
Regarding MCE::Shared and MCE::Shared::Handle, which have native-like usage, read behaves similarly to the native read function without the 'k' or 'm' suffix. The 'k' or 'm' suffix is extra functionality to get MCE-like chunking capabilities. Basically, to have read continue reading till the end of line.
# this feels closer to Perl-like read with extra functionality
$n_chars = read $fh, $buf, "4k";
# this is another option, but involves more typing
@lines = tied(%{$fh})->getlines(500);
$fh is a tied object so that it can be used natively. The extra behaviour applies to read only for chunk IO capabilities. Currently, it is not 100% parity with MCE, because Perl's read function cannot store into an array. Therefore, I may have MCE::Shared and MCE:::Shared::Handle export "mce_read", mentioned here, to have 100% parity with MCE's chunking engine.
Regards, Mario.
|