Can you clarify what you mean by "is not working for me" and "will not run correctly"?
Basic debugging includes validating your assumptions. This can be tedious but often discloses the root cause of the problem, in my experience. I often find it easiest to log details to the terminal or a file, depending on the situation. Data::Dumper is very handy for logging data structures. In an undisclosed subroutine, almost anything could be going on so, as others have said, more information is necessary to provide more specific suggestions.