Programming Perl in UNIX Course Number : CIT 370 Week 3 Prof. Daniel Chen.

Slides:



Advertisements
Similar presentations
1 Chapter Five Selection and Repetition. 2 Objectives How to make decisions using the if statement How to make decisions using the if-else statement How.
Advertisements

Objectives Using functions to organize PHP code
PHP Functions and Control Structures. 2 Defining Functions Functions are groups of statements that you can execute as a single unit Function definitions.
Chapter 4 Control Structures I. Objectives ► Examine relational and logical operators ► Explore how to form and evaluate logical (Boolean) expressions.
Chapter 5 Selection Statements. Topics Controlling program flow selection –if –switch Boolean expressions –boolean primitive type –comparison operators.
Conditions What if?. Flow of Control The order of statement execution is called the flow of control Unless specified otherwise, the order of statement.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 4: Control Structures I (Selection)
Chapter 4 Functions and Control Structures PHP Programming with MySQL.
COMP 14 Introduction to Programming Miguel A. Otaduy May 18, 2004.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
1 Lecture 7:Control Structures I (Selection) Introduction to Computer Science Spring 2006.
16/27/ :53 PM6/27/ :53 PM6/27/ :53 PMLogic Control Structures Arithmetic Expressions Used to do arithmetic. Operations consist of +,
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 5 Selection Statements Primitive Type boolean.
Tutorial 4 Decision Making with Control Structures and Statements Section A - Decision Making JavaScript Tutorial 4 -Decision Making with Control.
C++ for Engineers and Scientists Third Edition
Visual C++ Programming: Concepts and Projects
 2008 Pearson Education, Inc. All rights reserved JavaScript: Control Statements II.
Programming Perl in UNIX Course Number : CIT 370 Week 4 Prof. Daniel Chen.
EGR 2261 Unit 4 Control Structures I: Selection  Read Malik, Chapter 4.  Homework #4 and Lab #4 due next week.  Quiz next week.
CS0004: Introduction to Programming Relational Operators, Logical Operators, and If Statements.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 4 Decision Structures and Boolean Logic.
Decision Structures and Boolean Logic
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
Chapter 4: Decision Making with Control Structures and Statements JavaScript - Introductory.
1 Chapter 4: Selection Structures. In this chapter, you will learn about: – Selection criteria – The if-else statement – Nested if statements – The switch.
CPS120: Introduction to Computer Science Decision Making in Programs.
Flow of Control Part 1: Selection
PHP Conditional Statements Conditional statements in PHP are used to perform different actions based on different conditions. Conditional Statements Very.
ITM 352 Flow-Control: if and switch. ITM © Port, KazmanFlow-Control - 2 What is "Flow of Control"? Flow of Control is the execution order of instructions.
PHP Programming with MySQL Slide 4-1 CHAPTER 4 Functions and Control Structures.
Slide 1 PHP Operators and Control Structures ITWA 133.
Chapter 2 Functions and Control Structures PHP Programming with MySQL 2 nd Edition.
Control Structures By Shyam Gurram. Control Structure In this chapter we have two different types of structures. Conditional Structure Iterative Control.
A First Book of ANSI C Fourth Edition Chapter 4 Selection.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
4.1 Object Operations operators Dot (. ) and new operate on objects The assignment operator ( = ) Arithmetic operators + - * / % Unary operators.
Programming 1 DCT 1033 Control Structures I (Selection) if selection statement If..else double selection statement Switch multiple selection statement.
Week 8: Decisions Bryan Burlingame 21 October 2015.
JavaScript, Fourth Edition
Chapter 15 JavaScript: Part III The Web Warrior Guide to Web Design Technologies.
Quiz 3 is due Friday September 18 th Lab 6 is going to be lab practical hursSept_10/exampleLabFinal/
Chapter 4 Control Structures I. Chapter Objectives Learn about control structures Examine relational and logical operators Explore how to form and evaluate.
Flow of Control Unless indicated otherwise, the order of statement execution through a method is linear: one after the other in the order they are written.
Computer Programming TCP1224 Chapter 5 The Selection Structure.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 8 Java Fundamentals Control Structures Fri.
CPS120: Introduction to Computer Science Decision Making in Programs.
Programming Perl in UNIX Course Number : CIT 370 Week 2 Prof. Daniel Chen.
Perl Chapter 3 Conditional statements. Control Expressions Control expressions – interpreted as T/F (evaluated as strings or numbers) – simple, relational,
JavaScript, Sixth Edition
Random Functions Selection Structure Comparison Operators Logical Operator
Selection (if-then-else) Programming Has 3 Types of Control: Sequential (normal): Control of Execution Proceeds One after the Other Selection (if-then-else):
C++ for Engineers and Scientists Second Edition Chapter 4 Selection Structures.
Loops causes program to execute the certain block of code repeatedly until some conditions are satisfied. Suppose you want to execute some code/s 10 times.
Unit-1 Introduction to Java
Chapter 5 - Control Structures: Part 2
EGR 2261 Unit 4 Control Structures I: Selection
Expressions and Control Flow in JavaScript
JavaScript: Control Statements.
JavaScript: Control Statements I
Flow of Control.
Loop Control Structure.
Flow of Control.
Making Decisions in a Program
Control Structures: Selection Statement
Flow of Control.
Microsoft Visual Basic 2005: Reloaded Second Edition
Chapter 4: Control Structures I (Selection)
Program Flow.
Chapter 4: Boolean Expressions, Making Decisions, and Disk Input and Output Prof. Salim Arfaoui.
Control Structures: Selection Statement
Presentation transcript:

Programming Perl in UNIX Course Number : CIT 370 Week 3 Prof. Daniel Chen

Introduction n Review and Overviews n Chapters 5 and 6 n Summary n Lab n Quiz 1 n Next Week (Week 4)

Topics of Discussion n About Perl Operators n Mixing Data Types n Precedence and Associativity n Control Structures, Blocks, and Compound Statements n Decision Making – Conditional Constructs n Loops

Chapter 5: Where’s the Operators? n 5.1 About Perl Operators n 5.2 Mixing Data Types n 5.3 Precedence and Associativity

5.1 About Perl Operators n An operator manipulates data objects called operands.

5.2 Mixing Date Types n Data Conversion (overloading) n How Strings Are Converted to Numbers u Table 5.1

5.3 Precedence and Associativity n Precedence refers to the way is which the operator binds to its operand. n Associativity refers to the order in which an operator evaluates its operands: left to right, or right to left. u Table 5.2 n Assignment Operators u Table 5.3 n Relational Operators u Table 5.4

5.3.3 Equality Operators n Numeric u Table 5.6 n String u Table 5.7

5.3.4 Logical Operators n Unless C, the short-circuit operators do not return 0 (false) or 1 (true), but rather the value of the last operand evaluated. u Table 5.8 n Logical Word Operators (and, or, xor) u These logical word operators are of lower precedence than the short-circuit operators, but work the same way.

5.3.6 Arithmetic Operators Table 5.9 n Autoincrement and autodecrement operators u Table 5.10

Other Operators n Bitwise Logical Operators u TABLE 5.12 & Table 5.13 n Conditional Operators u Format: conditional expression ? expression : expression n Range Operator n Special String Operators and Functions u Table 5.14 n Generating Random Numbers u The rand/srand Functions

Chapter 6: If Only, Unconditionally, Forever n 6.1 Control Structures, Blocks, and Compound Statements n 6.2 Decision Making – Conditional Constructs n 6.3 Loops

Control Structures, Blocks, and Compound Statements n The decision-making constructs (if, if/else, if/elsif/else, unless, etc.) contains a control expression that determines whether a block of statements will be executes. n The looping constructs (while, for, foreach) allow the program to repetitively execute a statement block until some condition is satisfied. n A compound statement or block consists of a group of statements surrounded by curly braces. n Unlike C, Perl requires curly braces even one statement when that statement comes after the if, else, while, etc.

Decision Making-Conditions Constructors n if and unless Statements u The if Construct u The if/else Construct u The if/elseif/else Construct u The unless Construct

Loops n The while loop n The until loop n The do/while and do/until Loops n The for Loop n The foreach Loop

Loop Control n labels n next (continue) n last (break) n redo -it restarts the block without evaluating the loop expression again n goto n A Labeled Block Without a Loop n Nested Loops and Labels n The continue Block n The Phoney Switch Statement

Summary n About Perl Operators n Mixing Data Types n Precedence and Associativity n Control Structures, Blocks, and Compound Statements n Decision Making – Conditional Constructs n Loops

Lab n Examples 5.1 – 5.22 (P 101 – 129) n Examples (P ) n Homework 3

Quiz 1 n Quiz Date: Today n Quiz Time: 11:00 AM - 11:30 AM n Contents: Chapter 1- Chapter 4 n No books, no notes, no computer

Next Week n Reading assignment (Textbook chapter 7 and Chapter 8)