There are some code snippets in the O'Reilly book Mastering Algorithms with Perl. All the example programs are available online here.
Download "examples.tar.gz" or "examples.zip", and the examples you'll probably want will be in the "ch08" subdirectory. I don't know for sure that you'll find exactly what you need, but hopefully it will put you on the right track. Good luck!