I'm sorry, but it is unclear to me what "seeing this result on web application" actually means. Where do the data come from? Is your Perl code running as part of the web application, or did you write a web client and are trying to decode a response? How did you build $teststr, and how is it different from the example in my code? Where did you insert the code we suggested?
In particular, my code example does not return anything, so I can't connect to "returning the same result". Without context, I can't offer any more.