I think you show the progression from extremely simple to comprehend but overly verbose, gradually into a much more acceptable solution in a very fine way that should be easy to follow and learn from.
I think that your progression ends at a nice place too, unless one work in a shop where perl is a primary language.