Introducing System Managers to Win32 Perl Programming Tim Christian College of Arts and Sciences Computing Support Services
Welcome! This course: n is for people who know some other programming language and n should enable you to manage the network, write reports, and write CGI scripts using Perl.
Course Outline n About Perl n Installing Perl n Writing Perl n Debugging Perl n Extending Perl n Applying Perl Using Regular Expressions n Applying Perl for CGI
About Perl n Larry Wall n If you were to write a language that anybody could use, what would be some characteristics of that language?
Installing Perl n Normally, from: n For a limited time from n After installing Perl, how do you get help? n Your personal task before next class: Install Perl on your computer at work and/or home.
Writing Perl n Comments n Statements n Programs n Data Types n Data Type Operators n Flow Control n File Operators
Comments n First line comments, like: #!/usr/bin/perl n Other Comments n Example: ment.pl
Statements n Every part of a Perl script (except comments) consists of a statement. n Contain one or more function calls, L/Rvalues, and flow controls. n End with a semicolon (;). n Perl ignores all white space. n Example: ement.pl
Programs n Running from the command line. n Running from a file. n Example:
Data Types n Scalars: ar.pl n Arrays: y.pl n Associative arrays: ocarray.pl n The $_ variables.
Data Types Comparators n To compare characters: eq, ne, lt, gt, le, ge n To compare numbers: ==, !=,, = n Mnemonic: Always use characters to compare characters. n More: local/doc/manual/html/pod/perlop.h tml
Flow Control n If/else: n For: n Foreach: n Subroutines: ne.pl
File Operators n Special <> notation for the identifier. n Useful functions: open, close n Uses redirection symbols: >, >, <<, | n Example:
Debugging Perl n What is a debugger? n What is the best debugger? n Perl’s -d switch.
Extending Perl n Functions: local/doc/manual/html/pod/perlfunc.html n Modules: n Getting help with modules. n Using Modules.
Account Builder n Use flow control and subroutines and good coding style to: u Read in a file of names (like “Tim Christian”). u Create 8 character IDs based on those names until does not exist. n Hint: You might want to check out the length() and substr() functions.
Next Class n Bring your account builder solution to class n Regular expressions n Applying regular expressions in Perl