Dear Gods,...Hello

*I have been trying all day to no avail,..PLEASE HELP*

I have data like this
-------------------- 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] * ******************************************************************
All I am trying to do is to create a data structure (i.e a Hash) where I can populate it like so;
$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
I have tried all day with so many different variations of the code below and still getting nowhere very fast!
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"; } }
Maybe a second fresh pair of eyes can spot where and why I am going wrong!!

Thanks a million again.
Blackadder

In reply to Splitting data into chunks! by blackadder

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.