in reply to is it possible?

Yes.

What have you tried? How would you do it without a computer? How would you transform that method to Perl? Where are you stuck? Show your code!