2. Given that line $l$ passes through vertex $A, B$ of square $A B C D$, $B E \perp l$ at point $E, D F \perp l$ at point $F, B E=3, D F$ $=4$. Then the length of $E F$ is $\qquad$ .
2.1 or 7.

As shown in Figure 6, when $l$ is outside the square $A B C D$, it is easy to see that
$$
\begin{array}{l}
\triangle A B E \cong \triangle D A F \\
\Rightarrow A E=D F=4, A F=B E=3 \\
\Rightarrow E F=A F+A E=7 .
\end{array}
$$

As shown in Figure 7, when $l$ passes through the interior of the square $A B C D$, it is easy to prove that
$$
\begin{array}{l}
\triangle A B E \cong \triangle D A F \\
\Rightarrow A F=B E=3, A E=D F=4 \\
\Rightarrow E F=A E-A F=1 .
\end{array}
$$