If you don't mind keeping "WINGFRAME " in your elements use zero-width look-behind and -ahead assertions to split at points in the string that are not preceded by beginning of string and are followed by "WINGFRAME ".

$ perl -Mstrict -MData::Dumper -wle ' > my $line = q{WINGFRAME MACH1;VECTORTHRUST 40 00 40 40;VECTORTHRUST +60 00 40 90;VECTORTHRUST 10 40 30 10;VECTORTHRUST 80 10 10 10;VECTORT +HRUST 60 10 95 00;VECTORTHRUST 70 00 60 00;VECTORTHRUST 80 00 70 90;V +ECTORTHRUST 60 50 80 90;VECTORTHRUST 60 40 80 10;WINGFRAME MACH2;VEC +TORTHRUST 40 00 40 40;VECTORTHRUST 60 00 40 90;VECTORTHRUST 10 40 30 +10;VECTORTHRUST 80 10 10 10;VECTORTHRUST 60 10 95 00;VECTORTHRUST 70 +00 60 00;VECTORTHRUST 80 00 70 90;VECTORTHRUST 60 50 80 90;VECTORTHRU +ST 60 40 80 10;}; > my @arr = split m{(?x) (?<!\A) (?=WINGFRAME )}, $line; > print Data::Dumper->Dumpxs( [ \ @arr ], [ qw{ *arr } ] );' @arr = ( 'WINGFRAME MACH1;VECTORTHRUST 40 00 40 40;VECTORTHRUST 60 00 + 40 90;VECTORTHRUST 10 40 30 10;VECTORTHRUST 80 10 10 10;VECTORTHRUST + 60 10 95 00;VECTORTHRUST 70 00 60 00;VECTORTHRUST 80 00 70 90;VECTOR +THRUST 60 50 80 90;VECTORTHRUST 60 40 80 10;', 'WINGFRAME MACH2;VECTORTHRUST 40 00 40 40;VECTORTHRUST 60 00 + 40 90;VECTORTHRUST 10 40 30 10;VECTORTHRUST 80 10 10 10;VECTORTHRUST + 60 10 95 00;VECTORTHRUST 70 00 60 00;VECTORTHRUST 80 00 70 90;VECTOR +THRUST 60 50 80 90;VECTORTHRUST 60 40 80 10;' ); $

If you really don't want the "WINGFRAME " text then remove it by substitution in a map.

$ perl -Mstrict -MData::Dumper -wle ' > my $line = q{WINGFRAME MACH1;VECTORTHRUST 40 00 40 40;VECTORTHRUST +60 00 40 90;VECTORTHRUST 10 40 30 10;VECTORTHRUST 80 10 10 10;VECTORT +HRUST 60 10 95 00;VECTORTHRUST 70 00 60 00;VECTORTHRUST 80 00 70 90;V +ECTORTHRUST 60 50 80 90;VECTORTHRUST 60 40 80 10;WINGFRAME MACH2;VEC +TORTHRUST 40 00 40 40;VECTORTHRUST 60 00 40 90;VECTORTHRUST 10 40 30 +10;VECTORTHRUST 80 10 10 10;VECTORTHRUST 60 10 95 00;VECTORTHRUST 70 +00 60 00;VECTORTHRUST 80 00 70 90;VECTORTHRUST 60 50 80 90;VECTORTHRU +ST 60 40 80 10;}; > my @arr = > map { s{WINGFRAME }{}; $_ } > split m{(?x) (?<!\A) (?=WINGFRAME )}, $line; > print Data::Dumper->Dumpxs( [ \ @arr ], [ qw{ *arr } ] );' @arr = ( ' MACH1;VECTORTHRUST 40 00 40 40;VECTORTHRUST 60 00 40 90;VEC +TORTHRUST 10 40 30 10;VECTORTHRUST 80 10 10 10;VECTORTHRUST 60 10 95 +00;VECTORTHRUST 70 00 60 00;VECTORTHRUST 80 00 70 90;VECTORTHRUST 60 +50 80 90;VECTORTHRUST 60 40 80 10;', ' MACH2;VECTORTHRUST 40 00 40 40;VECTORTHRUST 60 00 40 90;VEC +TORTHRUST 10 40 30 10;VECTORTHRUST 80 10 10 10;VECTORTHRUST 60 10 95 +00;VECTORTHRUST 70 00 60 00;VECTORTHRUST 80 00 70 90;VECTORTHRUST 60 +50 80 90;VECTORTHRUST 60 40 80 10;' ); $

I hope this is helpful.

Cheers,

JohnGG


In reply to Re: split function gives emply line as output of the array element by johngg
in thread split function gives emply line as output of the array element by garbage777

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.