Perl Assignment #1:  Introduction to Perl

 

CS 447/647

Spring, 2012

 

 

Due: 2/7/12

 

Read chapter 1 of Learning Perl.  Do the 3 exercises at the end of the chapter.

Use the script program to capture the output from exercises 1 and 3.

 

Make your Perl scripts executable by using the chmod command:

 

chmod u+x filename.pl

 

Refer to the UNIX man pages for more information on these commands:

 

man chmod

man script

 

Be sure to see the Perl notes below.

 

Capture the output to be turned in:

 

script assign1.txt

PS1=’$ ‘

cat ex1-1

perl ex1-1

..

cat ex1-3

perl ex1-3

exit

 

Submit assign1.txt in Web Campus.  Be sure the file you submit ends with .txt

 

 

Hands-On Exercise

 

Work through the “Setup Your Web Presence” exercise linked to from the class website.

 

Note #1:

 

Answers to the exercises are located in Appendix A in Learning Perl.

 

Use these to check your work.  I will only check your assignments for completeness, not for accuracy.  I will assume you have already checked your answers against Appendix A.

 

You will have trouble on the tests if you copy your answers from Appendix A without trying to work them out on your own first.

 

 

 

 

Note #2:

 

The program script will generate a script of your terminal session. All the commands you type and the output will be logged in the file called typescript.  Use an editor to cleanup the log if you make errors during your session and prune any excessive output (i.e. If your script generates 1000 lines of output, delete everything but the first 5 and last 5.)

.

 

script assign1.txt

> ls –l

> cat ex1-1

> ./ex1-1

> exit

 

 

Note #3:

 

You can get the Perl examples from the O’Reilly website - Click on Download Example Code

 

http://shop.oreilly.com/product/0636920018452.do

 

unzip Learning_Perl_sample_files.zip

                         

You’ll learn more if you type in some of the examples in by hand.