in reply to RegEx & Approach Question
And the output is:#!/usr/bin/perl use warnings; use strict; my $file = "My file "; my $currentInterface = "Cisco Interface X"; while(<DATA>) { my $input_drops = 0; my $output_drops = 0; $input_drops = $1 if ( m{queue:\s+\d+/\d+/(\d+)/\d+} ); $output_drops = $1 if ( m{drops:\s+(\d+)$} ); printf("%-20.20s %-22.22s : $.\n",$file,$currentInterface) if ( $input_drops or $output_drops ); } __DATA__ Input queue: 0/75/0/39 (size/max/drops/flushes); Total output drops: +19845805
C:\Code>perl regex-test.pl My file Cisco Interface X : 1
|
|---|