%% ================================================================================ %% This LaTeX file was created by AbiWord. %% AbiWord is a free, Open Source word processor. %% You may obtain more information about AbiWord at www.abisource.com %% ================================================================================ \documentclass[12pt]{article} \usepackage[T1]{fontenc} \usepackage{calc} \usepackage{hyperref}\usepackage{setspace} \usepackage{multicol} \usepackage[normalem]{ulem} \usepackage{color} \setlength{\oddsidemargin}{1.250000in-1in} \setlength{\textwidth}{\paperwidth - 1.250000in-1.250000in} \begin{document} \begin{center} \end{itemize} \end{slide} \begin{slide}{An Overview of Perl} \begin{itemize} \end{center} \begin{center} A language for Systems and Network Administration and Management: \end{center} \begin{center} An overview of the language \end{center} \item \end{itemize} \end{slide} \begin{slide}{Where do I get Perl?} \begin{itemize} \item For Windows, go to http://www.activestate.com, download the installer \item For Linux: it will be already installed \item For other platforms: go to http://www.perl.com \item This is a good source of other information about Perl \item \end{itemize} \end{slide} \begin{slide}{Where do I get Info about Perl?} \begin{itemize} \item Web sites: \item http://www.perl.com \item http://www.activestate.com \item http://use.perl.org \item On your hard disk: \item perldoc --f }\textit{{function} \item Will look up the documentation for the built-in }\textit{{function}}{ (from the documentation perlfunc) \item perldoc --q }\textit{{word} \item Will look up }\textit{{word}}{ in the headings of the FAQ \item perldoc perl \item A list of much of your locally installed documentation, divided into topics \item ActiveState Perl provides a Programs menu item that links to online html documentation \item \item \end{itemize} \end{slide} \begin{slide}{CPAN, PPM: Many Modules} \begin{itemize} \item A very strong feature of Perl is the community that supports it \item There are tens of thousands of third party modules for many, many purposes: \item Eg. Net::LDAP module supports all LDAP operations, Net::LWP provides a comprehensive web client \item Installation is easy: \item \textbf{ sudo perl --MCPAN --e shell} \item \textbf{ install Net::LDAP} \item Will check if a newer version is available on the Internet from CPAN, and if so, download it, compile it, test it, and if it passes tests, install it. \item \end{itemize} \end{slide} \begin{slide}{PPM: Perl Package Manager} \begin{itemize} \item For Windows \item Avoids need for a C compiler, other development tools \item Download precompiled modules from ActiveState and other sites, and install them: \item ppm install Net::LDAP \item See documentation with ActiveState Perl \item \end{itemize} \end{slide} \begin{slide}{Mailing Lists: help from experts} \begin{itemize} \item There are many mailing lists and newsgroups for Perl \item When subscribe to mailing list, receive all mail from list \item When send mail to list, all subscribers receive \item For Windows, many lists at http://www.activestate.com \item \end{itemize} \end{slide} \begin{slide}{How to ask Questions on a List} \begin{itemize} \item I receive many email questions from students about many topics \item Most questions are not clear enough to be able to answer in any way except, ``please tell me more about your problem'' \item Such questions sent to mailing lists are often unanswered \item Need to be concise, accurate, and clear \item see also Eric Raymond's }\textit{{How to Ask Questions the Smart Way}}{ at }{http://catb.org/\~{}esr/faqs/smart-questions.html}{ \item Search the FAQs first \item \end{itemize} \end{slide} \begin{slide}{Where is Perl on my system?} \begin{itemize} \item ActiveState Perl installs }perl.exe}}{ in }\textbf{{C:\ensuremath{\backslash}Perl\ensuremath{\backslashperl.exe \item Linux systems have a standard location for perl at /usr/bin/perl \item On some UNIX systems, it may be installed at /usr/local/bin/perl \item \end{itemize} \end{slide} \begin{slide}{How does my OS know it's a Perl program?} \begin{itemize} \item To run your Perl program, OS needs to call perl \item How does OS know when to call Perl? \item Windows: \item OS uses the extension of the file to decide what to do (e.g., }.bat}}{, }\textbf{{.exe{) \item Your program names end with .pl \item Linux, Unix: \item programs have }\textit{{execute}}{ permission (}chmod +x }}\textbf{\textit{{program}{) \item OS reads first 2 bytes of program: if they are ``}\#!{'' then read to end of line, then use that as the interpreter \item OS doesn't care what your program file is called \item For cross platform support: \item Put this at the top of all your programs: \item \#! /usr/bin/perl --w \item Name your programs with an extension .pl \item \begin{center} \end{itemize} \end{slide} \begin{slide}{Language Overview} \begin{itemize} \end{center} \begin{center} A quick look at more important features of the language \end{center} \item \end{itemize} \end{slide} \begin{slide}{Funny Characters \$, @, \%} \begin{itemize} \item Variables in Perl start with a \textit{funny character} \item Why? \item No problem with reserved words: \item can have a variable called \$while, and another variable called @while, and a third called \%while. \item Can \textit{interpolate} value into a string: \item my \$string = ``long''; \item my \$number = 42.42; \item print ``my string is \$string and my number is \$number\ensuremath{\backslash}n''; \item \end{itemize} \end{slide} \begin{slide}{Arrays} \begin{itemize} \item Define an array like this: \item my @array = ( 1, 5, ``fifteen'' ); \item This is an array containing three elements \item The first can be accessed as \$array[0], second as \$array[1], the last as \$array[2] \item Note that since each element is a scalar, it has the \$ funny character for a scalar variable \textit{value} \item In Perl, we seldom use an array with an index---use list processing array operations \item higher level. \item \item \end{itemize} \end{slide} \begin{slide}{Hashes} \begin{itemize} \item Hashes are probably new to you \item Like an array, but indexed by a string \item Similar idea was implemented in java.lang.HashTable \item Perl hashes are easier to use \item Example: \item \textbf{my \%hash = ( NL => 'Netherlands',} \item \textbf{ BE => 'Belgium' );} \item This creates a hash with two elements \item first is \$hash\{NL\}, has value ``Netherlands''; \item second is \$hash\{BE\} with value "Belgium" \item \item \end{itemize} \end{slide} \begin{slide}{String Operations} \begin{itemize} \item Perl has all the operators from C, in same precedence \item Has more operators for strings: \item Join strings with a dot, e.g. \item print "The sum of 3 and 4 is " . 3 + 4 . "\ensuremath{\backslash}n"; \item Quote special characters with a backslash, as in C \item \textbf{ print "\ensuremath{\backslash}\$value = \$value\ensuremath{\backslash}n";} \item Can quote all characters using single quotes: \item print 'output of \$perl = "rapid";print \$perl; is "rapid"'; \item Note that double quotes are okay in single quotes, single quotes okay in double quotes. \item \item \end{itemize} \end{slide} \begin{slide}{See the perl summary} \begin{itemize} \item The Perl summary on the subject web site provides\ldotswell, a good summary! \item \end{document}