$elem[0] = "SHAPES GREEN1;SIZE 240 500 340 930;SIZE 350 500 240 590;SIZE 295 390 015 490;SIZE 350 210 760 300;"; $elem[1] = "SHAPES GREEN2;SIZE 450 310 680 690;SIZE 450 110 680 490;SIZE 215 800 560 900;"; #### my @matches = ( $inp_line =~ /(SHAPES \w+;(?:SIZE[ \d+])+;)/g ); #### my @matches; for ( @inp_lines ) { push @matches, ( /(SHAPES \w+;(?:SIZE[ \d+])+;)/g ); } #### s/(?<=\d;)(?=SHAPES )/\n/; # using "look-behind" and "look-ahead # now just split on "\n"...