in reply to Parsing cisco router command output

Lets go through this line by line (much of this was caught with the warnings and strict pragmas)
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 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).
Line 2. You should add use strict; here :)
Line 13. Warnings would have told you that this line does nothing: Useless use of push with no values at E:\111.pl line 13. What you probably meant was something like:
push @aoutput, $_ unless /matches\)$/;
Line 17. See line 13, same issue.
Line 25. I would assume you want a for loop as opposed to a while loop.
Line 26. I would think that if there were anything in @aoutput1 that everything would match. Also you wanted @linetemp, as opposed to $linetemp.
Line 27. $_=$linetemp will always evaluate to true, as long as $linetemp something Perl considers true.

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:

unless (/matches\)$/) { $no_match_day_two{$_} = 1 }
2. Open the day one files and do the same.
3. If i want to see the lines in day two that were not in day one, something like this would work (though with a few changes it can be made to show the ones in day one that were not in day two:
foreach my $match ( keys %no_match_day_two ) { print $match unless exists $no_match_day_one{$_}; }
As for an array of day one stuff not in day two something like this would work:
@nmday_one_but_not_nmdtwo = grep { exists $no_match_day_two{$_} } keys + %no_match_day_one;
I hope this helps.

-enlil