in reply to Fast Way to Split String in to Chunk of Equal Length
use strict; use warnings; my ($handle, $buffer, $size, @parsed, $i); open($handle, 'my-data.txt'); while ($size = read($handle, $buffer, 30)) { for ($i = 0; $i < $size; $i += 10) { push @parsed, [ substr($buffer, $i, 3), substr($buffer, $i+3, 3), substr($buffer, $i+6, 3) ]; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Fast Way to Split String in to Chunk of Equal Length
by TJPride (Pilgrim) on Nov 25, 2011 at 16:48 UTC |