I am trying to get a count of each line
sub runit2 {
my ($file1a, $file2a) = @;
my $file1_vala = $file1a->get;
my $file2_vala = $file2a->get;
open (FILE1a, "$file1_vala") or die;
open (FILE2a, "$file2_vala") or die;
chomp(my @strings = <FILE2a>);
while (1) {
foreach $pattern (<FILE1a>) {
chomp($pattern);
last if $pattern =~ /^\s*$/;
my @matches = eval {
grep $pattern eq $, @strings;
};
if ($@) {
print "Error: $@";
} else {
my $count = @matches;
print "$count $pattern \n",
#$text->insert('end', "$count $pattern $_\n");
}
}
return;
}
1 ip routing
1 ip classless
1 no ip bootp server
1 no ip http server
1 no ip http secure-server
1 ip bgp-community new-format
1 no access-list 23
1 no access-list 51
1 logging buffered 4096 debugging
1 banner motd ^
6 *************************************************
6**************************************************
2 ^
1 banner exec ^
6**************************************************
2 * LEGAL NOTICE *
6 ***************************************************
6 ***************************************************
2 * LEGAL NOTICE *
6 ****************************************************
2 ^
1 ip dhcp excluded-address 10.8.26.1 10.8.26.100
1 ip dhcp excluded-address 10.8.26.200 10.8.26.254
1 no auto-summary
1 snmp-server view BLOCK iso included
1 snmp-server view BLOCK ipAddrEntry.*.*.*.*.* included
1 snmp-server view BLOCK ipAddrEntry.*.10.*.*.* excluded
1 snmp-server view BLOCK ipNetToMediaEntry.*.*.*.*.*.* included
1 snmp-server view BLOCK ipNetToMediaEntry.*.*.10.*.*.* excluded
1 snmp-server view BLOCK atEntry.*.*.*.*.*.*.* included
1 snmp-server view BLOCK atEntry.*.*.*.10.*.*.* excluded
2 snmp-server ifindex persist
2 snmp-server enable traps snmp authentication linkdown linkup coldstart warmstart
1 snmp-server enable traps frame-relay
1 snmp-server enable traps frame-relay subif
1 snmp-server enable traps config
1 ip tacacs source-interface loopback0
1 snmp-server trap-source loopback0
1 ip flow-export source fa0/0
1 ip flow-export version 5 origin-as
1 ip flow-export destination 10.15.1.2 9996
1 ip flow-cache timeout active 1
1 ip flow-cache timeout inactive 15
2 snmp-server ifindex persist
1 logging trap notifications
1 logging source-interface fa0/0
2 snmp-server enable traps snmp authentication linkdown linkup coldstart warmstart
1 privilege exec level 1 traceroute
1 privilege exec level 1 ping
1 privilege exec level 1 show configuration
1 line con 0
2 exec-timeout 5 0
3 login
1 line aux 0
2 exec-timeout 5 0
3 login
1 line vty 0 4
1 exec-timeout 30 0
1 no privilege level 15
1 no access-class 23 in
3 login
1 end
The easiest thing to look at is the 3 login lines. login appears in file 2 3 times. I only want a single output of "3 login" and not that statement every time the script encounters login.