in reply to Re^4: Breaking up a string?
in thread Breaking up a string?
Now, that is a rather naive solution, it's not very effective, nor is it very perl'ish, but I think you might understand what is happening.use strict; use warnings; my $input = '1234562234563334564444565555566789'; my @sets_of_six; while (length $input > 6){ my $front = substr($input, 0, 6); $input = substr($input, 6); push @sets_of_six, $front; } push @sets_of_six, $input if length $input > 0; use Data::Dumper; print Dumper( @sets_of_six );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Breaking up a string?
by dsheroh (Monsignor) on Feb 19, 2008 at 18:18 UTC | |
by stiller (Friar) on Feb 19, 2008 at 20:26 UTC |