Thanks everyone for your input. Your examples were enlightening. Here is the entire script if anyone has any further suggestions. Thanks again!
----Sample text---- P4-RTR-1>show interface ATM4/0/0 is up, line protocol is up Hardware is cyBus ENHANCED ATM PA, address is 00d0.03a9.33fc (bia 00 +d0.03a9.33fc) Description: (REMOVED) MTU 4470 bytes, sub MTU 4470, BW 44209 Kbit, DLY 1900 usec, reliability 255/255, txload 1/255, rxload 1/255 Encapsulation ATM, loopback not set Keepalive not supported Encapsulation(s): AAL5, PVC mode 4095 maximum active VCs, 1 current VCCs VC idle disconnect time: 300 seconds 7505 carrier transitions Last input 00:00:00, output 00:00:05, output hang never Last clearing of "show interface" counters never Input queue: 0/75/0/39 (size/max/drops/flushes); Total output drops: + 1984580 Queueing strategy: fifo Output queue: 0/40 (size/max) 5 minute input rate 2000 bits/sec, 2 packets/sec 5 minute output rate 1000 bits/sec, 2 packets/sec 6619976463 packets input, 4546821473409 bytes, 0 no buffer Received 0 broadcasts (9406304 IP multicasts) 0 runts, 0 giants, 0 throttles 1013 input errors, 1259 CRC, 0 frame, 0 overrun, 0 ignored, 0 abo +rt 4952767077 packets output, 2922582936024 bytes, 0 underruns 0 output errors, 0 collisions, 1 interface resets 0 output buffer failures, 0 output buffers swapped out ----Script---- #!/usr/bin/perl my $filesProcessed = 0; @files = <*.grab>; foreach $file (@files) { open(F, $file); my @import=<F>; close(F); my $currentInterface; foreach my $line(@import) { chomp($line); if ($line =~ m/ATM(.)\/(.)\/(.)/) { $currentInterface = "ATM$1/$2/$3"; } if ($line =~ m/Ethernet(.)\/(.)/) { $currentInterface = "Ethernet$1/$2"; } if ($line =~ m/FastEthernet(.)\/(.)/) { $currentInterface = "FastEthernet$1/$2"; } if ($line =~ m/GigabitEthernet(.)\/(.)/) { $currentInterface = "GigabitEthernet$1/$2"; } if ($line =~ m/10GigabitEthernet(.)\/(.)/) { $currentInterface = "10GigabitEthernet$1/$2"; } if ($line =~ m/Hssi(.)\/(.)/) { $currentInterface = "Hssi$1/$2"; } if ($line =~ m/Vlan(.)/) { $currentInterface = "Vlan$1"; } if ($line =~ m/ Input queue: (.*)\/(.*)\/(.*)\/(.*) \(size\/m +ax\/drops\/flushes\); Total output drops: (.*)/) { printf("%-30.30s %-22.22s $line\n",$file,$currentInterface +) if ($3 || $4 || $5); } if ($line =~ m/ (.) packets input, (.) bytes, (.) no buffe +r/) { printf("%-30.30s %-22.22s $line\n",$file,$currentInterface +) if ($3); } if ($line =~ m/ Received (.) broadcasts, (.) runts, (.) gi +ants, (.) throttles/) { printf("%-30.30s %-22.22s $line\n",$file,$currentInterface +) if ($1 || $2 || $3); } if ($line =~ m/ (\d) input errors, (.) CRC, (.) frame, (.) + overrun, (.) ignored/) { printf("%-30.30s %-22.22s $line\n",$file,$currentInterface +) if ($1 || $2 || $3 || $4 || $5); } if ($line =~ m/ (.) watchdog, (.) multicast, (.) pause inp +ut/) { printf("%-30.30s %-22.22s $line\n",$file,$currentInterface +) if ($1 || $3); } if ($line =~ m/ (.) input packets with dribble condition d +etected/) { printf("%-30.30s %-22.22s $line\n",$file,$currentInterface +) if ($1); } if ($line =~ m/ (.) packets output, (.) bytes, (.) underru +ns/) { printf("%-30.30s %-22.22s $line\n",$file,$currentInterface +) if ($3); } if ($line =~ m/ (.) output errors, (.) collisions, (.) int +erface resets/) { printf("%-30.30s %-22.22s $line\n",$file,$currentInterface +) if ($1 || $2 || $3); } if ($line =~ m/ (.) babbles, (.) late collision, (.) defer +red/) { printf("%-30.30s %-22.22s $line\n",$file,$currentInterface +) if ($1 || $2 || $3); } if ($line =~ m/ (.) lost carrier, (.) no carrier, (.) paus +e output/) { printf("%-30.30s %-22.22s $line\n",$file,$currentInterface +) if ($1 || $2 || $3); } if ($line =~ m/ (.) output buffer failures, (.) output buf +fers swapped out/) { printf("%-30.30s %-22.22s $line\n",$file,$currentInterface +) if ($1 || $2); } } $filesProcessed++; } print "\nFiles Processed: $filesProcessed\n";

In reply to Re: RegEx & Approach Question by ewhitt
in thread RegEx & Approach Question by ewhitt

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.