+ All Categories
Home > Documents > Prof. Alfred J Bird, Ph.D., NBCT [email protected] Door Code for IT441 Students – 142864* Office...

Prof. Alfred J Bird, Ph.D., NBCT [email protected] Door Code for IT441 Students – 142864* Office...

Date post: 02-Jan-2016
Category:
Upload: barrie-peters
View: 214 times
Download: 0 times
Share this document with a friend
Popular Tags:
12
Prof. Alfred J Bird, Ph.D., NBCT [email protected] http://it441-f11-campbell.wikispaces.umb.edu/ Door Code for IT441 Students – 142864* Office – Wheatly 2nd floor 096-03 Office Hours – MW 3:00PM to 4:00PM
Transcript
Page 1: Prof. Alfred J Bird, Ph.D., NBCT abird@cs.umb.edu  Door Code for IT441 Students – 142864* Office – Wheatly.

Prof. Alfred J Bird, Ph.D., [email protected]

http://it441-f11-campbell.wikispaces.umb.edu/

Door Code for IT441 Students – 142864*

Office – Wheatly 2nd floor 096-03Office Hours – MW 3:00PM to 4:00PM

Page 2: Prof. Alfred J Bird, Ph.D., NBCT abird@cs.umb.edu  Door Code for IT441 Students – 142864* Office – Wheatly.

Perl normally treats lines beginning with a # as a comment.

Get in the habit of including comments with your code.

Put a comment block at the beginning of your code which includes your name, the name of the module, date written and the purpose of the code.

Page 3: Prof. Alfred J Bird, Ph.D., NBCT abird@cs.umb.edu  Door Code for IT441 Students – 142864* Office – Wheatly.

q// single quoted string qq// double quoted string

In qq// the // can be replaced with any other non-alphanumeric character provided you use the same character on both ends of the string

Page 4: Prof. Alfred J Bird, Ph.D., NBCT abird@cs.umb.edu  Door Code for IT441 Students – 142864* Office – Wheatly.

$a = “123” $b = “456”

What do we get if we write this line of code,

print $a + $b;

How about this line of code, print $a . $b;

Page 5: Prof. Alfred J Bird, Ph.D., NBCT abird@cs.umb.edu  Door Code for IT441 Students – 142864* Office – Wheatly.

** Exponentiation - Unitary Negation * Multiplication / Division % Modulo (Remainder) + Addition - Subtraction

Page 6: Prof. Alfred J Bird, Ph.D., NBCT abird@cs.umb.edu  Door Code for IT441 Students – 142864* Office – Wheatly.

In mathematics and computer science, an algorithm is an effective method expressed as a finite list of well-defined instructions for calculating a function. Algorithms are used for calculation, data processing, and automated reasoning. In simple words an algorithm is a step-by-step procedure for calculations.

Page 7: Prof. Alfred J Bird, Ph.D., NBCT abird@cs.umb.edu  Door Code for IT441 Students – 142864* Office – Wheatly.

To use a file we need to attach a filehandle to it.

We do this using the open statement. A simple example:

open (OUT1, “>testoutout.txt”); If we open it we want to close it after we

are done: Close (OUT1);

By convention a filehandle is codded in all capital letters

Page 8: Prof. Alfred J Bird, Ph.D., NBCT abird@cs.umb.edu  Door Code for IT441 Students – 142864* Office – Wheatly.

We want to know for sure that we were successful opening the file so we include a test:

Open (OUT1, “>>test.txt”) or die $!;

Page 9: Prof. Alfred J Bird, Ph.D., NBCT abird@cs.umb.edu  Door Code for IT441 Students – 142864* Office – Wheatly.

To use a filehandle you wrap it in angle brackets.

Print <OUT1> “Hello World!\n”; chomp ($in = <IN1>);

Page 10: Prof. Alfred J Bird, Ph.D., NBCT abird@cs.umb.edu  Door Code for IT441 Students – 142864* Office – Wheatly.

Remember what the redirectors do:

>

>>

<

Page 11: Prof. Alfred J Bird, Ph.D., NBCT abird@cs.umb.edu  Door Code for IT441 Students – 142864* Office – Wheatly.

1. Calculate the first 50 prime numbers and write them to an output file.

2. Calculate the first 40 members of the Fibonacci Series and write them to an output file.

3. Letter guessing game4. Number guessing game using <=>

Page 12: Prof. Alfred J Bird, Ph.D., NBCT abird@cs.umb.edu  Door Code for IT441 Students – 142864* Office – Wheatly.

Complete the four programming exercises.


Recommended