On Friday 05 August 2005 01:37, Jason Normandin wrote: [..] > > if ($protocol =~ /PING REQUEST/) { > push @{$pingRequests{$destination}}, { > time => $time, > sequenceNumber=>$sequenceNumber > }; > } > elsif ($protocol =~ /PING RESPONSE/) { > push @{$pingResponses{$source}}, { > time => $time, > sequenceNumber=>$sequenceNumber [..]
> 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 > > }; > } > Hi Jason, I think you might want to take a look at the map function - using it, you could do something like this: my $response = $pingResponse{$destination}; my $responseTime; map { $responseTime = ($response->{'time'} - $_->{'time'}) if ($_->{'sequenceNumber'} == $response->{'sequenceNumber'}) } @{$pingRequests{$destination}}; > DOes that make any sense? Can I do what I am trying to accomplish using the > logic above? If so, what is that syntax? I'm not sure if I would approach your problem the same way - I don't know what exactly you need to have as result, but I would think about storing all request/response pairs in a hash with the sequence number as key. This might make things easier. HTH, Philipp -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>