There is a big discussion going on in the chat room, about this thread, as there are several different interpretations of what the author is actually trying to do.
As for whether there is a more perlier way, I would say, any solution that solves the problem, looks normal, easy to understand would be a good one.