in reply to dividend with recursive routine
This is a job for *subroutines(wo|man)*!! Sorry I don't have time to give you a proper answer, but check out perlsub and read up on subroutines (i.e. recursively used 'functions', such as your dividend calculator) - the important bit is passing info in and out.
Hope this helps, and sorry for the brief answer...
Just a something something...
In Section
Seekers of Perl Wisdom