in reply to Regular Expression Trick
And the output is -#!/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|
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
|
|---|