I can't offer you any specific advice (I don't think you've told us enough for that), so consider this general advice that may, or may not, apply
- Can you override the function that prints? That's what I did the last time I had a problem similar to yours.
- I'm a (fairly recent) big fan of test-driven development. If you can't work out how to test a method/subroutine, you need to think more about how you can make the subroutine easier to test
If you consider the second point, it means you think about your test first and then code it. Then write some code that makes your program pass the test.
There's some really good reading in Extreme Perl.