in reply to Regular Expression Trick

How about this attempt - do not hardcode your regular expression, use a 'split' on record boundary instead.
#!/usr/local/bin/perl -w use strict; chomp(my @lines = <DATA>); my @array; foreach (@lines) { foreach (split /(?<!\w)(?=\w+::\w+::\w+)/) { # <- split on record bo +undary s/\|$//; # get rid of the last | on the line push @array, $_; } } print "$_\n" for @array; __DATA__ monsa::clear::1|red::23|blue::50|monsb::clear::80|red::90|blue::100| monsc::clear::1|red::23|blue::50|green::50|monsd::clear::80|red::90|
And the output is -
monsa::clear::1|red::23|blue::50 monsb::clear::80|red::90|blue::100 monsc::clear::1|red::23|blue::50|green::50 monsd::clear::80|red::90