\documentclass[12pt]{article}
\topmargin -10.8truemm
\textheight 218truemm
\oddsidemargin 0.0truemm
\evensidemargin 0.0truemm
\textwidth 165truemm
% remove all page numbers
\renewcommand{\thepage}{\mbox{}}
\begin{document}
\begin{center}
{\Large CSc 265---F96---Quiz 5 (Time: 20 min.)}
\end{center}
%
\begin{tabbing}
Student name:1\=\underline{\hspace{3in}}1\=Lab Section:1\=\kill
Student name:\>\underline{\hspace{3in}}\>Lab Section:\>\underline{\hspace{.75in}}
\end{tabbing}
%
\noindent{\bf Note}:
\begin{itemize}
\item
Write your answers on this paper.
\item
After a pattern has been evaluated against a string $s$:
if the pattern contained any expressions in parentheses,
then \verb+$1+ contains the portion of $s$ that matched the first expression,
\verb+$2+ contains the portion that matched the second expression, and
\verb+$3+ contains the portion that matched the third expression.
\end{itemize}
%
\begin{enumerate}
\item (7 points)
Write the {\it exact output\/} of the following Perl program:
\begin{verbatim}
$s = "abbcccddddeeeee";

$s =~ s/b+/X/;
print "$s\n";

$s =~ s/(d+)/"Y" x length($1)/e;
print "$s\n";

$s =~ s/(.*[A-Z]+)([a-z]+)([A-Z]+.*)/$3$2$1/;
print "$s\n";
\end{verbatim}
\vspace{20mm}
%
\item (3 points)
Write the {\it exact output\/} of the following Perl program:
\begin{verbatim}
%g = ("e","x", "c","v", "w","c", "v","e", "x","w");

$n = "x";

while (!defined($p{$n})) {
    print "$n ";
    $p{$n} = 0;
    $n = $g{$n};
}
\end{verbatim}
%
\end{enumerate}
%
\end{document}
