% This document was generated automagically by lgrind. DO NOT EDIT. \documentclass[solutions]{ictlab} \RCS $Revision: 1.1 $ \usepackage{lgrind,verbatim,alltt} \usepackage[pdfpagemode=None,pdfauthor={Nick Urbanik}]{hyperref} \newcommand*{\labTitle}{An Introduction to Perl} \begin{document} Log into your VTC student email account. I have sent you an email (using a Perl program, of course!) that tells you your password for our laboratory computer system. Please read this email, then log into your Linux account. Open the editor of your choice; available options are: \texttt{emacs}, \texttt{xemacs}, \texttt{vi}, \texttt{gvim}, \texttt{gnp}, \texttt{pico}, \texttt{gedit}, and many others. \paragraph{How to read about built in Perl functions:} There is a huge amount of documentation about Perl installed on your computer. The Perl built-in functions are all described in detail in the \texttt{perlfunc} man page. But there is a handy tool for reading about a single built-in function: \texttt{perldoc -f \emph{function}} This works in Windows as well as Linux\\LGinlinetrue\LGbegin\lgrinde\L{\LB{.}} The man page for perl operators is called \texttt{perlop}. \begin{enumerate} \item Write a program that calculates the circumference of a circle with a radius of 12.5. The circumference is $C=2\pi r$, and $\pi \approx 3.1415927$. \s{ \begin{verbatim} #! /usr/bin/perl -w use strict; our $pi = 3.1415927; our $r = 12.5; our $c = 2 * $pi * $r; print "Circumference of a circle with radius $r is $c\n"; \end{verbatim}%$ } \item Modify the program you just wrote to prompt for and read the radius from the person who runs the program. \item Write a program that prompts for and reads two numbers, and prints out the result of multiplying the two numbers together. \item Write a program that prompts for and reads a string and a number, and prints the string the number of times indicated by the number, on separate lines. Hint: read about the ``\texttt{x}'' operator. \item Write a program that works like \texttt{cat}, but reverses the order of the lines. It should read the lines from files given on the command line, or from standard input if no files are given on the command line. Hint: read about the built-in \texttt{reverse} function. You will want to use an array. \end{enumerate} \end{document}