I think that sometimes it is the real purpose of write a script: solve a problem fast.
If you refactor a simple code like this, probaly you will waste time... And what was the initial purpose? That's right, avoid wasting time. Nice example, thank you for sharing with us.
That is such a great point! And it's premature optimization to start refactoring this in case it could become useful as a general script in the future.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.