R
Russell.Mottram
Hi,
I'm currently studying a relatively basic PERL course, and have an end
of semester assignment due very soon.
I've managed to get through everything so far, except I'm now stuck on
the very last bit, which is printing a comparison between two hashes.
Essentially, the problem is this:
The system log (system.evt) has been searched for Telnet entries, and
positive matches have been moved into %TelnetEntry.
Then the security log (security.evt) has been searched for users who
were logged on at the time, excluding Network Service, Local Service,
and one other random user. Users have been moved into %SecTime.
I now need to iterate through both to determine at the time the Telnet
service was started, who was logged on?
This is the code I'm working on:
while (($TelnetTime,$Telnetvalue)= each(%TelnetEntry))
{
while (($SecTime,$SecUser) = each(%SecTime))
{
if ($SecTime < $TelnetTime) # If the time the user logged on is less
than the time that Telnet was started, then do the following:
{
print "\n";
print "The Telnet Service was run by $SecTime{$SecTime}"; #
Prints the user logged on at that time.
print "\n";
print "The time was: ".scalar localtime $TelnetTime; # Prints the
time that Telnet was started. The key and value are the same in this
hash.
print "\n";
}
}
}
I'm pretty sure the problem lies in - if ($SecTime < $TelnetTime) - as
the current result of this code running is that all of the values in
both tables are printing out.
We haven't covered while loops inside while loops in much detail, and
I can't help but think that this problem is so easy that I'm going to
be quite annoyed when it is actually figured out. I know something is
missing!!
Please help... ASAP if possible
Cheers
Russ
I'm currently studying a relatively basic PERL course, and have an end
of semester assignment due very soon.
I've managed to get through everything so far, except I'm now stuck on
the very last bit, which is printing a comparison between two hashes.
Essentially, the problem is this:
The system log (system.evt) has been searched for Telnet entries, and
positive matches have been moved into %TelnetEntry.
Then the security log (security.evt) has been searched for users who
were logged on at the time, excluding Network Service, Local Service,
and one other random user. Users have been moved into %SecTime.
I now need to iterate through both to determine at the time the Telnet
service was started, who was logged on?
This is the code I'm working on:
while (($TelnetTime,$Telnetvalue)= each(%TelnetEntry))
{
while (($SecTime,$SecUser) = each(%SecTime))
{
if ($SecTime < $TelnetTime) # If the time the user logged on is less
than the time that Telnet was started, then do the following:
{
print "\n";
print "The Telnet Service was run by $SecTime{$SecTime}"; #
Prints the user logged on at that time.
print "\n";
print "The time was: ".scalar localtime $TelnetTime; # Prints the
time that Telnet was started. The key and value are the same in this
hash.
print "\n";
}
}
}
I'm pretty sure the problem lies in - if ($SecTime < $TelnetTime) - as
the current result of this code running is that all of the values in
both tables are printing out.
We haven't covered while loops inside while loops in much detail, and
I can't help but think that this problem is so easy that I'm going to
be quite annoyed when it is actually figured out. I know something is
missing!!
Please help... ASAP if possible
Cheers
Russ