Hello
I have a situation where I build an anonymous array of hashes for some requests
and responses found in a file (there can be multiple requests and responses).
It works very nicely and tracks all of the responses and requests from an ip to
another IP address.
Here is my code:
my $time=$1 if /^(\d+:\d+:\d+\.\d+)/;
my $source=$1 if /(\S+) -> \S+/;
my $destination=$1 if /\S+ -> (\S+)/;
my $sourcePort=$1 if /S=(\d+)/;
my $destinationPort=$1 if /D=(\d+)/;
my $sequenceNumber=$1 if /Sequence number: (\d+)/;
if ($protocol =~ /PING REQUEST/) {
push @{$pingRequests{$destination}}, {
time => $time,
sequenceNumber=>$sequenceNumber
};
}
elsif ($protocol =~ /PING RESPONSE/) {
push @{$pingResponses{$source}}, {
time => $time,
sequenceNumber=>$sequenceNumber
};
}
I can then access the contents via code like:
foreach my $record(@{$pingRequests{$request}}) {
$requestCount++;
print "\tRequest Time=$record->{time}\n" if defined $details;
}
What I want to do however is track the response time between a request and
response. This would be identified by the same sequence number for a
request/respone pair. I would like to take the time value for each and subtract
the response time from the request time to get the response time and add that
to the response hash.
I cannot figure out how to access the contents of the anonymous hash for that
one value.
Sudo code would be:
elsif ($protocol =~ /PING RESPONSE/) {
responseTime=pingRequests{$source}->time -
pingResponses{$destination)->time if pingRequests{$source}->sequenceNumber =
pingResponses{$destination}->sequenceNumber;
push @{$pingResponses{$source}}, {
time => $time,
sequenceNumber=>$sequenceNumber
responseTime=>$responseTime
};
}
DOes that make any sense? Can I do what I am trying to accomplish using the
logic above? If so, what is that syntax?
Help!
Thanks!
Jason
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>