blackadder has asked for the wisdom of the Perl Monks concerning the following question:
All I am trying to do is to create a data structure (i.e a Hash) where I can populate it like so;-------------------- show port-channel database ------------------ port-channel 1 Administrative channel mode is on Operational channel mode is on Last membership update succeeded First operational port is fc1/5 2 ports in total, 2 ports up Ports: fc2/5 [up] fc1/5 [up] * port-channel 3 Administrative channel mode is on Operational channel mode is on Last membership update succeeded First operational port is fc1/1 1 port in total, 1 port up Ports: fc1/1 [up] * ******************************************************************
I have tried all day with so many different variations of the code below and still getting nowhere very fast!$Rec->{Port_Channel_Name} = "port-channel 1" $Rec->{port_member} = fc2/5 $Rec->{port_member} = fc1/5 . . . $Rec->{port_member} = fcX/X $Rec->{Port_Channel_Name} = "port-channel 3" $Rec->{port_member} = fc1/1
Maybe a second fresh pair of eyes can spot where and why I am going wrong!!for my $Info (@Switch_Array) { if ($Info =~/show port-channel database/) { next unless ($Info ne ""); my @Filter = (split /(port-channel \d\n)/,$Info); print "$1 : $Filter[0]\n"; # for my $Filtered (@Filter) # { # print "$Filtered \n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Splitting data into chunks!
by ikegami (Patriarch) on Sep 20, 2005 at 18:27 UTC | |
|
Re: Splitting data into chunks!
by kwaping (Priest) on Sep 20, 2005 at 18:42 UTC | |
by blackadder (Hermit) on Sep 21, 2005 at 10:43 UTC | |
|
Re: Splitting data into chunks!
by salvix (Pilgrim) on Sep 20, 2005 at 18:41 UTC | |
|
Re: Splitting data into chunks!
by Roy Johnson (Monsignor) on Sep 20, 2005 at 18:40 UTC | |
|
Re: Splitting data into chunks!
by sh1tn (Priest) on Sep 20, 2005 at 19:22 UTC | |
by blackadder (Hermit) on Sep 21, 2005 at 08:59 UTC | |
by sh1tn (Priest) on Sep 21, 2005 at 09:15 UTC | |
|
Re: Splitting data into chunks!
by gargle (Chaplain) on Sep 20, 2005 at 18:51 UTC | |
by blackadder (Hermit) on Sep 21, 2005 at 07:30 UTC |