This is all about knowing the data. You have to understand the realms of the world you're working in.
1. The first value in a rule can only be Source or Destination.
2. The second value is the name of a value in the packet.
3. The third value is the value in the packet itself.
Correct?
Then knowing that, start constructing the same guidelines of the data for the ip packets themselves. Know where in the packet you can find whether it's a source or not. Know where the ip is stored and the domain is stored. Once you know all that, it's a simple matching.
As you've said, it's vague as to which part of the assignment you're actually having trouble with. If it's not the logic of it, and you're having trouble with coding something that goes through a file line by line, then see below
use warnings;
use strict;
open(FH, '<', "rules.txt");
my @data = <FH>;
close FH;
foreach my $value (@data)
{
chomp($value);
my ($SourceorDestination, $name, $value) = split(/,/, $value);
#Insert compare code here
}
I know that many monks would tell you not to load the contents of the file into an array like I have, but I imagine that your rules file won't be huge and you'll be needing it every time you compare a packet.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.