Measuring the boundary of an irregular polygon

Hi

I have been set a programming task where I need to determine the length of the boundary of an irregular polygon between 3 and 6 sides, I am not asking for the programming part (as I know how to program) but just the maths behind how to calculate the length of the boundary of an irregular polygon, I will then be able to do myself, the conversion into programming language.

Thank you very much in advance if you can help me out with the maths involved in calculating the length of the boundary of an irregular polygon between 3 and 6 sides.