You are correct,… I understand it’s messy, so I decided to abandon this approach in favor of the approach below:
#! c:/perl/bin/perl.exe # # $|++; AUTOLOAD; use strict; use warnings 'all'; my $DataRec= {}; if (open(DATA,"c:\\logfile.txt")) { my ($pc_name, $Rec, $hash, $key, $Port, $PortDesc); print "\nExtracting data from c:\\logfile.txt\n\n"; while (<DATA>) { if (/^port-channel (\d+)$/) { $pc_name = $1; } elsif (m|(fc\d+/\d+)\s+\[(\w+)\]|) { $Rec->{$pc_name}->{$1} = $2; } elsif (/^interface port-channel (\d+)$/) { $key = $1; } elsif (/switchport description To (\w+) ([\d+\.]+)/) { $hash->{$key}->{$1} = $2; } #### Now I have a problem with the below ##### elsif (/^interface (fc\d+\/\d+)$/) { $Port = $1; } elsif (/\s+switchport description (.+)$/) { $PortDesc->{$Port} = $2 if ($2 ne ""); } ##################################### } for my $Port (keys %{$PortDesc}) { print "$Port : $PortDesc->{$Port}\n"; # no output for $PortDe +sc->{$Port}!!! } for my $Channel (keys %{$Rec}) { for my $Port (keys %{$Rec->{$Channel}}) { for my $Match (keys %{$hash}) { next unless ($Channel == $Match); $DataRec->{ISL}->{$Port}->{$_} = $hash->{$Match}->{$_} for + (keys %{$hash->{$Match}}); } } } &Create_Excel($DataRec); print "\n-------------------------\n"; Close DATA; } else { warn "$!\n"; } sub Create_Excel { my ($Record) = @_; print "\nISL Information \n"; for my $Port (keys %{$Record->{ISL}}) { print "$Port : "; for my $Name (keys %{$Record->{ISL}->{$Port}}) { print "$Name : $Record->{ISL}->{$Port}->{$Name}\n"; } } }
It seems that my problem is that I can't get all the data that I need unless I close DATA and oopen it again! Surely I can get all that I need from the first pass through...Righht!...Thnaks
Blackadder

In reply to Re^2: Why am I getting so many issues with REGEX!!!! by blackadder
in thread Why am I getting so many issues with REGEX!!!! 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.