To calculate the perimeter of a rectangle you have to add all of its sides, that is

You can simplify it as:

If you know the perimeter and width of a rectangle, you can calculate the length.
First write the formula in terms of the length:

For P=12mm and w=2mm

The length of a rectangle with perimeter of 12mm and width of 2mm is 4mm