in reply to Regex split at number of occurrence
This would be a good use of natatime
#!/usr/bin/env perl use strict; use warnings; use feature 'say'; use List::MoreUtils 'natatime'; my $string = "firstname1:::surname1:::middlename1:::firstname2:::surna +me2:::middlename2:::firstname3:::surname3:::middlename3"; my @arr; my $it = natatime (3, split (/:::/, $string)); while (my @these = $it->()) { push @arr, join ':::', @these; } say for @arr;
|
|---|