Thanks for the link. I did not want to use a module , but I wanted to understand the algorithmic approach of doing this in perl.
Perl is the only language I know well , so this was my only resort...
If you are interested in how the module does it, you can always look at the source on CPAN or on METACPAN. (In the general case, you search for the module on or , and they have a "Source" link.)