in reply to Re^5: Breaking up a string?
in thread Breaking up a string?
This can be done slightly more compactly by having the initial substr remove the leading characters as it retrieves them:while (length $input > 6){ my $front = substr($input, 0, 6); $input = substr($input, 6); push @sets_of_six, $front; }
(Or even get rid of $front entirely withwhile (length $input > 6){ my $front = substr($input, 0, 6, ''); push @sets_of_six, $front; }
if you don't think that's becoming too unreadable.)while (length $input > 6){ push @sets_of_six, substr($input, 0, 6, ''); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Breaking up a string?
by stiller (Friar) on Feb 19, 2008 at 20:26 UTC |