# How can I get lines to break automatically using the LaTeX listings package?

I am using the listings package to include sample Perl source code in LaTeX. I included the package with \usepackage{listings}, and used the following code:

\lstset{language=Perl}
$subject = "<owamp:subject xmlns:owamp=\"http://ggf.org/ns/nmwg/tools/owamp/2.0/\" id=\"subject\">\n"; \end{lstlisting}  The resulting output is: The line doesn't seem to breaking, but I read that lines break automatically when using the listings package. This line is the entire PDF snapshot of the code. Am I doing anything wrong as far as the code is concerned? - ## migrated from stackoverflow.comMay 13 '12 at 20:33 This question came from our site for professional and enthusiast programmers. ## 1 Answer Use breaklines=true: \documentclass{article} \usepackage{listings} \lstset{language=Perl} \lstset{commentstyle=\textit} \lstset{frame=shadowbox} \begin{document} \begin{lstlisting}[numbers=left, breaklines=true]$subject = "<owamp:subject xmlns:owamp=\"http://ggf.org/ns/nmwg/tools/owamp/2.0/\" id=\"subject\">\n";