Firstly, vector diagrams always help. Here is one for this situation
The blue line is line
l
The projection is the vector from A to the intersection of the purple and blue lines in the bottom right
The purple line is the 'perpendicular distance' we aim to solve for
The black line is vector
AP
The projection is perpendicular to the vector that it projects onto (line
l). So the intersection of the blue and purple lines is a right angle.
You now have a right-angled triangle. Solving by pythagoras' theorem gives the answer of