Line 1. You probably need to change this to #!/usr/bin/perl Though you might not depending on the system you are running (I know the AS Perl for windows will associate .pl files with perl).1 #/usr/bin/perl 2 3 print "Enter filename that contains output of show access <list\n" +; 4 chomp ($aoutput = <STDIN>); 5 print "Enter the second file\n"; 6 chomp ($aoutput1 = <STDIN>); 7 8 open (IN, $aoutput) || die "Couldn't open $aoutput $!"; 9 open (LOG, ">>matches.txt") || die "Couldn't open matches.txt $!"; 10 open (IN1, $aoutput1) || die "Couldn't open $aoutput1 $!"; 11 #Push each line in file 1 that does not get any matches into an ar +ray 12 while (<IN>){ 13 push @aoutput unless /matches\)$/; 14 } 15 #Push each line in file 2 that does not get any matches into an ar +ray 16 while (<IN1>){ 17 push @aoutput1 unless /matches\)$/; 18 } 19 20 #See if the lines that didn't get matches on day 1 didn't get matc +hes on day 2 as well 21 22 #Gotta be a better way to do this? 23 24 25 while (<@aoutput>){ 26 $linetemp = grep {/$_/i} @aoutput1; 27 if ($_ = $linetemp) { 28 print $_; 29 } 30 }
Line 17. See line 13, same issue.push @aoutput, $_ unless /matches\)$/;
Regardless this code will not do what you want. The way I would go about it is.
== A Different Approach ==
1. Open the day two file and grab all the lines you want and put them in a hash. Something like:
2. Open the day one files and do the same.unless (/matches\)$/) { $no_match_day_two{$_} = 1 }
As for an array of day one stuff not in day two something like this would work:foreach my $match ( keys %no_match_day_two ) { print $match unless exists $no_match_day_one{$_}; }
I hope this helps.@nmday_one_but_not_nmdtwo = grep { exists $no_match_day_two{$_} } keys + %no_match_day_one;
-enlil
In reply to Re: Parsing cisco router command output
by Enlil
in thread Parsing cisco router command output
by routedude
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |