Remove the join statement, then I think this does what you're after:

my %data; my $device; for (@check){ next if ! /\d{1,2}-\d{1,2}/; chomp; s/\s+//g; if (/EQUIP-OME/){ $device = $_; next; } push @{$data{$device}}, $_; } for my $device (keys %data){ for my $interface (@{$data{$device}}){ print "$device,$interface\n"; } }

Output:

EQUIP-OME815-08-2615:19:27,"ETH10G-1-13-2,ETH10G:OPT-OCH,-3.20,COMPL,N +END,TRMT,1-DAY,08-25,00-00,1,,,," EQUIP-OME815-08-2615:19:27,"ETH10G-1-13-2,ETH10G:OPRN-OCH,-17,COMPL,NE +ND,RCV,1-DAY,08-25,00-00,1,,,," 115-EQUIP-OME515-08-2615:19:26,"OC12-1-4-7,OC12:OPRN-OCH,-79,COMPL,NEN +D,RCV,1-DAY,08-25,00-00,1,,,," 115-EQUIP-OME515-08-2615:19:26,"OC12-1-4-7,OC12:OPTN-OCH,0,ADJ,NEND,TR +MT,1-DAY,08-25,00-00,1,,,," 115-EQUIP-OME515-08-2615:19:26,"OC12-1-4-8,OC12:OPR-OCH,-14.04,COMPL,N +END,RCV,1-DAY,08-25,00-00,1,,,," EQUIP-OME115-08-2615:19:13,"OC192-1-1-2,OC192:OPR-OCH,-10.20,COMPL,NEN +D,RCV,1-DAY,08-25,00-00,1,,,," EQUIP-OME115-08-2615:19:13,"OC192-1-1-2,OC192:OPT-OCH,-3.50,COMPL,NEND +,TRMT,1-DAY,08-25,00-00,1,,,," 123-EQUIP-OME215-08-2615:19:25,"OC12-1-3-7,OC12:OPRN-OCH,-89,COMPL,NEN +D,RCV,1-DAY,08-25,00-00,1,,,," 123-EQUIP-OME215-08-2615:19:25,"OC12-1-3-7,OC12:OPTN-OCH,0,ADJ,NEND,TR +MT,1-DAY,08-25,00-00,1,,,,"

-stevieb


In reply to Re^3: Parsing/Splitting data by stevieb
in thread Parsing/Splitting data by acondor

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.