#$last_value{ $id } = $payload; $last_value{ $id } ||= {}; if(defined $last_value{ $id } ) { $last_value{ $id }{COUNT} += 1; # If we last saw something from this device, note the time difference if( $last_value{ $id }{TIME} ) { $time_diff = $now_milli - $last_value{ $id }{TIME}; } else { # Otherwise, print 0 $time_diff= 0; };