Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

  Hiya routedude,
I added <code> tags around your example code, and tweaked some to make it clearer to my short-bus brain.   I found this syntax for matching-the-intersection-of-two-arrays on page 106 of The Perl Cookbook, and also moved the file opens/closes as close to each ofther as possible - always a good habit.
 
Anyways, I *think* this will do what you want or at least be close.   Wiser monks than I might show how to make it scale to more than just two days' acl log files.   The 'while... push unless /matches/' chunks could likely become a subroutine, but as is, this maybe shows some direction.
  cheers,
  ybiC
    striving toward Perl Adept
    (it's pronounced "why-bick")

==untested==
#/usr/bin/perl -w use strict; # define output+input filenames: my $outFile = 'aclLog.txt'; print "Enter filename that contains output of show access <list\n"; chomp my $aclMatchesDay2 = <STDIN>; print "Enter the second file\n"; chomp my $aclMatchesDay2 = <STDIN>; # check for no-matches in first input file: open (ACLM1, $aclMatchesDay1) or die "Couldn't open $aclMatchesDay1: $ +!"; while (<ACLM1>){ push @noMatchesDay1 unless /matches/; } close ACLM1 or die "Couldn't close $aclMatchesDay1: $!"; # check for no-matches in second input file: open (ACLM2, $aclMatchesDay2) or die "Couldn't open $aclMatchesDay2: $ +!"; while (<ACLM2>){ push @noMatchesDay2 unless /matches/; } close ACLM2 or die "Couldn't close $aclMatchesDay2: $!"; # check for overlap betwixt two input files: my %isect; foreach $e (@noMatchesDay1, @noMatchesDay2){ $isect{$e}++; } my $noMatchesEver = keys %isect; # print said overlap to output file: open (OUT, ">>$outFile") or die "Couldn't open $outFile: $!"; print "$_\n" for @noMatchesEver; close OUT or die "Couldn't close $$outFile: $!";

In reply to Re: Parsing cisco router command output (potential answer, untested) by ybiC
in thread Parsing cisco router command output by routedude

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2024-04-20 14:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found