in reply to split with a delimiter, every 4 time it occurs.
Don't make it so hard. Don't craft some ugly regexp or confusing split. Just keep it simple; split on commas, grab five at a time, print them, move on.
use List::MoreUtils qw(natatime); my $to_split = "'A','B','C','D','E','F','G','H','I','J','K','L','M','N +','O','P','Q','R','S','T','U','V','W','X','Y','Z'"; my $it = natatime 5, split /,/, $to_split; while( my @vals = $it->() ) { local $" = ','; print "@vals\t"; } print "\n";
...the output...
'A','B','C','D','E' 'F','G','H','I','J' 'K','L','M','N','O' ' +P','Q','R','S','T' 'U','V','W','X','Y' 'Z'
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: split with a delimiter, every 4 time it occurs.
by Anonymous Monk on Jul 01, 2013 at 08:09 UTC | |
by davido (Cardinal) on Jul 01, 2013 at 15:55 UTC | |
by locked_user sundialsvc4 (Abbot) on Jul 01, 2013 at 11:34 UTC |