\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 1 (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$:
\verb+$&+ contains the portion of $s$ that matched
and \verb+$'+ contains the part of $s$ after the matched part.
If the pattern contained any expressions in parentheses,
then \verb+$1+ contains the portion of $s$ that matched the first expression and
\verb+$2+ contains the portion of $s$ that matched the second expression.
\end{itemize}
%
\begin{enumerate}
\item (7 points)
In the space to the right, write the {\it exact output\/}
of the following Perl program:
\begin{verbatim}
@s = ('x',     'xx*$',
      'a[^a]', '.Y..',
      '^a.Y',  '(a(aa)+)+',
      '^\w*$'
);
$_ = "abcYaaaYx*";
for ($i = 0; $i < @s; $i++) {
    print "$i: ";
    if (/$s[$i]/) {
        print $&, "\n";
    } else {
        print "no match\n";
    }
}
\end{verbatim}
%
\item (3 points)
In the space to the right, write the {\it exact output\/}
of the following Perl program:
\begin{verbatim}
$s = "abc!!3xdef!de";

while (length($s) > 0) {
    if ($s =~ /^!([0-9]+)(.)/) {
        print $2 x $1,"_";
    } elsif ($s =~ /^![^!]*/) {
        print $&,"_";
    } elsif ($s =~ /^[^!]+/) {
        print $&,"_";
    }
    $s = $';
}
\end{verbatim}
%
\end{enumerate}
%
\end{document}
