Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (1)
As of 2024-04-16 00:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found