in reply to Setting the value of a complicated hash ref

If I were to run your code, to test it, I would use the
debugger. This way I could see what is actually going on
without digesting all the code right away. This is what you
should do. Break at that point in the code, and see
that url_encode() is returning what you expected.
You can also get a dump of any structure by typing 'x struct ref',
i.e 'x $characters', this will let you know if it is
getting properly filled. If you know this
already, I apologize. I find using the debugger lets me know what is
going on, and this is how I would test your code.