I'm not exactly sure of your desired output format, but how's this:
#!/usr/bin/perl use warnings; use strict; use Data::Dumper::Simple; my ($hash,$key); while(<DATA>) { $key = $1, next if (/interface port-channel (\d+)$/); $hash->{$key}->{$1} = $2 if (/switchport description To (\w+) ([\d +\.]+)/); } print Dumper($hash); __DATA__ vsan 1060 wwn 20:00:00:e0:69:41:26:e7 fcid 0x6d0d00 area dynamic vsan 1030 wwn 10:00:00:00:c9:28:29:44 fcid 0xa70001 dynamic vsan 1030 wwn 10:00:00:00:c9:28:2c:55 fcid 0xa70002 dynamic vsan 1060 wwn 50:06:0b:00:00:0b:3a:0e fcid 0x6d0e00 area dynamic vsan 1060 wwn 20:00:00:e0:69:41:3b:ca fcid 0x6d0f00 area dynamic vsan 1060 wwn 20:00:00:e0:69:40:d1:3f fcid 0x6d1000 area dynamic vsan 1060 wwn 20:00:00:e0:69:41:55:1f fcid 0x6d1100 area dynamic vsan 1060 wwn 20:00:00:e0:69:41:57:1e fcid 0x6d1200 area dynamic vsan 1060 wwn 10:00:00:00:c9:45:3a:21 fcid 0x6d0006 dynamic vsan 1060 wwn 20:00:00:e0:69:41:55:ff fcid 0x6d1300 area dynamic vsan 1050 wwn 50:06:0b:00:00:30:0d:f4 fcid 0x140100 area dynamic logging server 10.33.34.235 6 interface port-channel 1 switchport trunk allowed vsan 1000 switchport trunk allowed vsan add 1050 switchport description To CCC219 10.33.81.56 switchport mode E interface port-channel 3 switchport trunk allowed vsan 1000 switchport trunk allowed vsan add 1010 switchport trunk allowed vsan add 1050 switchport trunk allowed vsan add 1900 switchport description To CCC215 10.33.81.52 switchport mode E vsan database vsan 1050 interface port-channel 1 vsan 1060 interface fc1/3 vsan 1060 interface fc1/4 vsan 1060 interface fc1/8 vsan 1050 interface fc1/12 vsan 1060 interface fc1/14 vsan 1060 interface fc1/15 vsan 1010 interface fc1/16 vsan 1900 interface fc2/1 vsan 1060 interface fc2/3 vsan 1010 interface fc2/4 vsan 1050 interface fc2/7

Output:
$hash = { '1' => { 'CCC219' => '10.33.81.56' }, '3' => { 'CCC215' => '10.33.81.52' } };

In reply to Re: Another Challenge: Splitting data into chunks part2 by kwaping
in thread Another Challenge: Splitting data into chunks part2 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.