in reply to Re^2: Parsing/Splitting data
in thread Parsing/Splitting data

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

Replies are listed 'Best First'.
Re^4: Parsing/Splitting data
by acondor (Initiate) on Aug 27, 2015 at 12:53 UTC
    Thank you for that.

    It outputs correctly, but removes spaces between Equipment name, date, and time. I tried putting a comma to separate on blank spaces, which did work, but it also placed commas the rest of the responce (if there was blank spaces).

    How can this be modified to:

    1. Find equipment: ' 115-EQUIP-OME5 15-08-26 15:19:26

    2. chomp it with comma separation

    3. push to the rest of the string without affecting other lines

    Thank you

      How can this be modified to: ...

      Do you have any idea acondor?