Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^3: Parsing/Splitting data

by stevieb (Canon)
on Aug 26, 2015 at 16:14 UTC ( [id://1140066]=note: print w/replies, xml ) Need Help??


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?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1140066]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2024-03-28 22:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found