#!/usr/bin/perl use warnings; use strict; my $tmpipaccountingfile = "tmpipaccountingfile"; my $DestDevice = "Box"; foreach my $OuterData () { print "OuterData = $OuterData"; open TMPIPACCOUNTINGFILE, "<", "$tmpipaccountingfile"; foreach my $Line () { chomp $Line; next if ($Line =~ m/^sh/); next if ($Line =~ m/^\s*Source/); next if ($Line =~ m/^$DestDevice/); next if ($Line =~ m/^Accounting/); next if ($Line =~ m/^$/); next unless ($Line =~ m/^\s*\d*.\d*.\d*.\d*\s*$OuterData/); print "Line = $Line\n\n"; } close TMPIPACCOUNTINGFILE; } exit; __DATA__ 10.2.9.2 10.2.9.3 10.2.9.6