Let $L$ = length of the side in metres, and $P$ = posts bought.
Step 1: Posts needed for $6$ m spacing
If spacing is $6$ m, number of intervals = $L/6$, number of posts = $(L/6) + 1$.
He has $5$ less than this:
\[
P = \left(\frac{L}{6} + 1\right) - 5
\]
\[
P = \frac{L}{6} - 4 \quad (1)
\]
Step 2: Posts needed for $8$ m spacing
If spacing is $8$ m, posts = $(L/8) + 1$.
This equals his stock:
\[
P = \frac{L}{8} + 1 \quad (2)
\]
Step 3: Equate (1) and (2)
\[
\frac{L}{6} - 4 = \frac{L}{8} + 1
\]
Multiply by 24:
\[
4L - 96 = 3L + 24
\]
\[
L = 120
\]
Step 4: Find $P$
From (2):
\[
P = \frac{120}{8} + 1 = 15 + 1 = 16
\]
\[
\boxed{L = 120\ \text{m},\ P = 16}
\]