Actually unpack was suggested (and not implemented) by me first. ;)
FWIW: My idea was to unpack multiple lines simultaneously instead of going line by line.
If you are interested and all lines really have the same length (the OP never clarified)
Please see if substr on single lines is still faster then.
$line_length += $newline_length; # OS dependend $line_count = int(8 * 1024 / $line_length) +1; $chunk_size = $line_count * line_length;
And yes I'm still reluctant to implement it, smells too much like an XY Problem :)
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!
In hindsight... probably having a slightly smaller chunk is more efficient :
$line_count = int(8 * 1024 / $line_length)
In reply to Re^2: Faster and more efficient way to read a file vertically
by LanX
in thread Faster and more efficient way to read a file vertically
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |