Step 1: Condition for perpendicularity
If a line is perpendicular to two given lines with direction ratios \( (a_1, b_1, c_1) \) and \( (a_2, b_2, c_2) \), then its direction cosines \( (l, m, n) \) satisfy:
\[
a_1 l + b_1 m + c_1 n = 0,
\]
\[
a_2 l + b_2 m + c_2 n = 0.
\]
For the given lines:
1st line: \( (1,2,-1) \), so
\[
1l + 2m - 1n = 0.
\]
2nd line: \( (1,-2,1) \), so
\[
1l - 2m + 1n = 0.
\]
Step 2: Solving for \( l, m, n \)
Adding the two equations:
\[
(1+1)l + (2-2)m + (-1+1)n = 0.
\]
\[
2l = 0 \Rightarrow l = 0.
\]
Substituting \( l = 0 \) in the first equation:
\[
2m - n = 0 \Rightarrow n = 2m.
\]
Using the direction cosine condition:
\[
l^2 + m^2 + n^2 = 1.
\]
\[
0^2 + m^2 + (2m)^2 = 1.
\]
\[
m^2 + 4m^2 = 1.
\]
\[
5m^2 = 1 \Rightarrow m^2 = \frac{1}{5}.
\]
Step 3: Computing \( (l+m+n)^2 \)
\[
(l+m+n)^2 = (0 + m + 2m)^2 = (3m)^2 = 9m^2.
\]
\[
= 9 \times \frac{1}{5} = \frac{9}{5}.
\]
Step 4: Conclusion
Thus, the final answer is:
\[
\boxed{\frac{9}{5}}.
\]