Sorry, but without an error message or more information on the problem I don't think there is anything to be done. I have a couple suggestions though:
Indent your code - It makes it much easier and much clearer when dubugging
on this line if(exists $whop{'$onname'}){...}, I would suggest using no quotes because single quotes do not allow variable interpolation. So it probably should be if(exists $whop{$onname}){...}.
Other than that, I do not know. I hope I helped :)