1 / 18

IT441 Network Services Administration

IT441 Network Services Administration. Prof. Alfred J Bird, Ph.D., NBCT abird@cs.umb.edu http:// it441-s14-bird.wikispaces.umb.edu / Door Code 536587* Office – McCormick 3rd floor 607 Office Hours – Tuesday & Thursday 4:00Pm to 5:15PM. Program Comments. Start a comment with a #

blithe
Download Presentation

IT441 Network Services Administration

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. IT441Network Services Administration Prof. Alfred J Bird, Ph.D., NBCT abird@cs.umb.edu http://it441-s14-bird.wikispaces.umb.edu/ Door Code 536587* Office – McCormick 3rd floor 607 Office Hours – Tuesday & Thursday 4:00Pm to 5:15PM

  2. Program Comments • Start a comment with a # • Write many comments in your program • Write a header block in EVERY program # # Author: Al Bird # Name: firstName.pl # Date: 11 Sept 2013 # Purpose: To solve a problem #

  3. Four Domains of Programming Languages

  4. Four Domains of Programming Languages • Input / Output

  5. Four Domains of Programming Languages • Input / Output • Variables / Information Storage

  6. Four Domains of Programming Languages • Input / Output • Variables / Information Storage • Decision / Control Structures

  7. Four Domains of Programming Languages • Input / Output • Variables / Information Storage • Decision / Control Structures • Data Manipulations / Calculations

  8. Variables • What is a variable? • How do we name variables? • Starts with $ • Next either letter or _ • Rest can be letters or numbers • You should develop a pattern so you are consistent within your programs. • $userFirstName • $user_first_name • Make the name mean something!!!

  9. Getting Data into the Program • Use the file handle <STDIN> • Use the chomp() function • chomp (my $newInput = <STDIN>);

  10. Numerical Comparisions • == Equality • < Less Than • <= Less Than or Equal To • > Greater Than • >= Greater Than or Equal To

  11. Arithmetic Comparisons • $x > $y • $x < $y • $x >= $y • $x < =$y • $x == $y • $x != $y

  12. String Operators • . Concatenation • x Repetition • ord() ASCII Value of a character • lt Less Than • gt Greater Than • eq Equal To

  13. String Comparisions • $x gt $y • $x lt $y • $x ge $y • $x le $y • $x eq $y • $x ne $y

  14. Logical Operators • $x and $y • $x && $y • $x or $y • $x || $y • Not $x • !$x

  15. Ways to get out of a program • exit (0); • die $string;

  16. If Statements • if • if ( condition ) { action }

  17. Programming Exercises • Write a program to: • Input two numbers • Add, subtract, multiple and divide them • Write out the results in a formatted form i.e 3.7 + 4.1 = 7.8 3.7 – 4.1 = -0.4 • Write a program to: • Store a password in a variable • Input a string • Compare the stored password to the inputted string • Write a success or failure message

  18. Programming Exercises • Write a program to: • Read in two numbers • Decide which is larger • Print out the lower number then the higher number • Write a program to: • Read in five words • Sort them in ASCII order • Print out the five words in ASCII order

More Related