Perl

Tom Kelliher, CS 318

Jan. 21, 1999

Administrivia

Announcements

Assignment

Find three Perl resources on the Web and e-mail the URLs to me by 1:20pm on 1/24/00.

From Last Time

Threw around some course structure ideas.

Outline

  1. Perl: mechanics, variables, control, I/O, subroutines.

  2. Perl lab.

Coming Up

More Perl.

Perl Mechanics

  1. Phoenix accounts.

  2. Editing.

  3. Perl file extension: .pl.

  4. Making a Perl script executable: chmod.

  5. Documentation and readability.

  6. The ``magic'' line:
    #!/usr/local/bin/perl -w
    
    Why -w? Debugging help

  7. use strict; and my. Global vs. local variables.

Variables

  1. Scalars.

  2. Arrays/Lists. ``Length.'' Indexing as a scalar.

Control

  1. Blocks. Scoping.

  2. Conditions.

  3. If/Else. Elsif.

  4. While, for.

I/O

  1. STDIN, STDOUT, STDERR.

  2. Open(), close(), file handles.

  3. Line input with <FILEHANDLE>

  4. getc [FILEHANDLE]

Subroutines

  1. Prototype declaration.

  2. Definition:
    sub foo
    {
    ...
    }
    

  3. Parameter ``passing.''

  4. Parameter list in @_.

  5. Get next parameter:
    $foo = shift(@_);
    

Lab

Add a subroutine to cat.pl.



Thomas P. Kelliher
Fri Jan 21 12:09:38 EST 2000
Tom Kelliher