in reply to Stuck Value

I would do it in the simplest way possible:   the first data-structure that comes to mind.   This would be a hashref (of keys...) pointing to an arrayref (of values).

Each time you get a value, you unshift it onto the array.   If the number of entries in the array is now 6, shift off the first one and discard it, then check for identical runs.   (If not, you don’t have enough observations yet.)

The test for runs is also very straightforward:   a while loop.

In short, there is no reason for your coding to be “clever.”   (You are in no danger of running out of microseconds.)   The only thing that matters is that it is clear and maintainable.