If there's a question or request in there somewhere, I missed it. What's your point?
I don't know what "Sugar" is, and it's not clear how important it would be for me look that up in order to understand what you're trying to say.
Your first rendering of the "r2h" sub looks remarkably susceptible to injection attacks (or at least prone to crashes due to improper parameters being passed in and not taint-checked). The second "r2h" is even more so. I'd try to look for a less risky way to do whatever you're trying to do.