CSC 4630 Meeting 17 March 21, 2007. Exam/Quiz Schedule Due to ice, travel, research and other commitments that we all have: –Quiz 2, scheduled for Monday.

Slides:



Advertisements
Similar presentations
Ruby (on Rails) CSE 190M, Spring 2009 Week 2. Arrays Similar to PHP, Ruby arrays… – Are indexed by zero-based integer values – Store an assortment of.
Advertisements

Expressions and Statements. 2 Contents Side effects: expressions and statements Expression notations Expression evaluation orders Conditional statements.
PL/SQL.
Introduction to Programming Lesson 1. Objectives Skills/ConceptsMTA Exam Objectives Understanding Computer Programming Understand computer storage and.
String and Lists Dr. Benito Mendoza. 2 Outline What is a string String operations Traversing strings String slices What is a list Traversing a list List.
CS 898N – Advanced World Wide Web Technologies Lecture 8: PERL Chin-Chih Chang
CS311 – Today's class Perl – Practical Extraction Report Language. Assignment 2 discussion Lecture 071CS Operating Systems I.
CSC 4630 Meeting 9 February 14, 2007 Valentine’s Day; Snow Day.
True BASIC Ch. 6 Practice Questions. What is the output? PRINT X LET X = -1 PRINT X FOR X = 4 TO 5 STEP 2 PRINT X NEXT X PRINT X END.
Scripting Languages Chapter 6 I/O Basics. Input from STDIN We’ve been doing so with $line = chomp($line); Same as chomp($line= ); line input op gives.
ECE122 L11: For loops and Arrays March 8, 2007 ECE 122 Engineering Problem Solving with Java Lecture 11 For Loops and Arrays.
CS31: Introduction to Computer Science I Discussion 1A 4/2/2010 Sungwon Yang
Lecture 2 BNFO 135 Usman Roshan. Perl variables Scalar –Number –String Examples –$myname = “Roshan”; –$year = 2006;
Iteration and Simple Menus Deterministic / Non-deterministic loops and simple menus.
Perl Tutorial Presented by Pradeepsunder. Why PERL ???  Practical extraction and report language  Similar to shell script but lot easier and more powerful.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 9 More About Strings.
CIS 218 Advanced UNIX1 CIS 218 – Advanced UNIX (g)awk.
Chapter 4: Decision Making with Control Structures and Statements JavaScript - Introductory.
COMPUTER PROGRAMMING. Control Structures A program is usually not limited to a linear sequence of instructions. During its process it may repeat code.
Matlab Programming, part 1 M-files It is generally more convenient to program in Matlab using m-files, ascii text files containing a set of Matlab commands.
Meet Perl, Part 2 Flow of Control and I/O. Perl Statements Lots of different ways to write similar statements –Can make your code look more like natural.
Control Structures. if-elsif-else semantically the same as C/C++ syntactically, slightly different. if ($a > 0){ print “\$a is positive\n”; } elsif ($a.
Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
C++ crash course Class 8 statements, sort, flight times program.
Books. Perl Perl (Practical Extraction and Report Language) by Larry Wall Perl 1.0 was released to usenet's alt.comp.sources in 1987 Perl 5 was released.
Introduction to Unix – CS 21 Lecture 12. Lecture Overview A few more bash programming tricks The here document Trapping signals in bash cut and tr sed.
Perl: Lecture 1 The language. What Perl is Merger of Unix tools – Very popular under UNIX – shell, sed, awk Programming language – C syntax Scripting.
Revision Lecture Mauro Jaskelioff. AWK Program Structure AWK programs consists of patterns and procedures Pattern_1 { Procedure_1} Pattern_2 { Procedure_2}
Introduction to Unix – CS 21
BY A Mikati & M Shaito Awk Utility n Introduction n Some basics n Some samples n Patterns & Actions Regular Expressions n Boolean n start /end n.
Prof. Alfred J Bird, Ph.D., NBCT Office – McCormick 3rd floor 607 Office Hours – Tuesday and.
Computer Programming for Biologists Class 3 Nov 13 th, 2014 Karsten Hokamp
CS161 Topic #16 1 Today in CS161 Lecture #16 Prepare for the Final Reviewing all Topics this term Variables If Statements Loops (do while, while, for)
5 1 Data Files CGI/Perl Programming By Diane Zak.
LIN Unix Lecture 7 Hana Filip. LIN Text Processing Command Line Utility Programs (cont.) sed LAST WEEK wc sort tr uniq awk TODAY join paste.
Iteration While / until/ for loop. While/ Do-while loops Iteration continues until condition is false: 3 important points to remember: 1.Initialise condition.
More about Strings. String Formatting  So far we have used comma separators to print messages  This is fine until our messages become quite complex:
Perl Tutorial. Why PERL ??? Practical extraction and report language Similar to shell script but lot easier and more powerful Easy availablity All details.
CPTG286K Programming - Perl Chapter 4: Control Structures.
Copyright © 2003 ProsoftTraining. All rights reserved. Perl Fundamentals.
Loops Robin Burke IT 130. Outline Announcement: Homework #6 Conditionals (review) Iteration while loop while with counter for loops.
 In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.  PHP Loops :  In.
Jim Havrilla. Invoking Python Just type “python –m script.py [arg]” or “python –c command [arg]” To exit, quit() or Control-D is used To just use the.
Perl Variables: Array Web Programming1. Review: Perl Variables Scalar ► e.g. $var1 = “Mary”; $var2= 1; ► holds number, character, string Array ► e.g.
Midterm Exam Topics (Prof. Chang's section) CMSC 201.
Computer Programming for Biologists Class 4 Nov 14 th, 2014 Karsten Hokamp
1 Lecture 10 Introduction to AWK COP 3344 Introduction to UNIX.
INLS 560 – S TRINGS Instructor: Jason Carter. T YPES int list string.
PERL By C. Shing ITEC Dept Radford University. Objectives Understand the history Understand constants and variables Understand operators Understand control.
ORAFACT Text Processing. ORAFACT Searching Inside Files grep - searches for patterns within files grep [options] [[-e] pattern] filename [...] -n shows.
Introduction to Programming the WWW I CMSC Winter 2003 Lecture 17.
CSC 4630 Perl 3 adapted from R. E. Beck. Problem But we worked on it first: Input: Read from a text file named in a command line argument Output: List.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Winter 2016CISC101 - Prof. McLeod1 CISC101 Reminders Quiz 3 this week – last section on Friday. Assignment 4 is posted. Data mining: –Designing functions.
String and Lists Dr. José M. Reyes Álamo. 2 Outline What is a string String operations Traversing strings String slices What is a list Traversing a list.
String and Lists Dr. José M. Reyes Álamo.
CSC 4630 Meeting 7 February 7, 2007.
Control Flow Constructs: Conditional Logic
Lecture 6 Repetition Richard Gesick.
Chapter 5 - Control Structures: Part 2
Miscellaneous Items Loop control, block labels, unless/until, backwards syntax for “if” statements, split, join, substring, length, logical operators,
ITM 352 Flow-Control: Loops
Perl Variables: Array Web Programming.
Control Structures: for & while Loops
T. Jumana Abu Shmais – AOU - Riyadh
String and Lists Dr. José M. Reyes Álamo.
Topics Basic String Operations String Slicing
Shell Control Structures
Topics Basic String Operations String Slicing
Topics Basic String Operations String Slicing
Presentation transcript:

CSC 4630 Meeting 17 March 21, 2007

Exam/Quiz Schedule Due to ice, travel, research and other commitments that we all have: –Quiz 2, scheduled for Monday 3/19, was cancelled –Quiz 3, will replace Exam 2 on the calendar, so will occur on Wednesday, March 28 –Exam 2, will replace Quiz 3 on the calendar, so will occur on Monday, April 16

Project Schedule Projects 3 and 4 have been replaced by the team software development project Some short homework assignments may be given in their place.

Daily Scrum Questions for the technical advisor?

Computing News John Backus

Owen’s Problem But we worked on it first: Input: Read from a text file named in a command line argument Output: List of white-space delimited strings (ignoring case) with frequency counts ordered first by frequency and then lexicographically by ASCII character order. Format is

Owen’s Problem (2) What do we need to solve it in Perl? Read a line from a = <>; Read the whole file, line by line, and do something to each line while (<>) {something} Note that each line shows up in the variable $_ so that you don’t have to do an assignment statement if you don’t want to.

Owen’s Problem (3) Try 1: Make a one line input file: The quick brown fox Make a Perl program that reads and writes it: while (<>) {

Owen’s Problem (4) Try 2: Same program, put two lines in the input file. Try 3: Change the upper case to lower case. Perl knows about tr and assumes it works on $_ Syntax is tr/ab/cd/

Owen’s Problem (5) Try 4: Now we need to separate the array containing the current line into individual words. Perl can help with split which takes $_ by default, splits it on whitespace by default, and puts the result where you = split; Redo your program to handle this and print one word per line.

Owen’s Problem (6) Try 5: Collect the lines in an array and print the array, one word per line. Perl knows the array iteration similar to Awk: foreach { }. If you don’t specify a loop variable, Perl uses $_

Owen’s Problem (7) Try 6: We need the words in alphabetical order. Perl knows sort as a function on an = does the job. Fix your program so that it prints the words in lexicographic order, one per line.

Owen’s Problem (8) Try 7: Where is the UNIX uniq command when we need it?

Perl Control Structures Sequence: Statements separated or terminated by ; (semicolon) If-Then-Else: if (c) {s1} else {s2} Note that c as a conditional expression is false if its value is the string () or the single character 0 (zero). Otherwise c is true

Control Structures (2) Fancier If-Then-Else unless (c) {s} is equivalent to if (c) { } else {s} if (c1) {s1} elsif (c2) {s2} elsif (c3) {s3} … else {sn}

Control Structures (3) While-Do: while (c) {s} until (c) {s} is equivalent to while (!c) {s} do {s} while c is equivalent to s; while (c) {s}

Control Structures (4) We have the fourth version also do {s} unless c is equivalent to s; unless (c) {s}

Control Structures (5) Loops with “counters” for (e; c; i) {s} is equivalent to e; while (c) {s; i} Counter issues: –Loop variable local to loop? –Value of loop variable after loop exit?

Control Structures (6) foreach $i {s} The variable $i ranges over the values of the array and can be referenced by s foreach {s} Uses the default index variable $_ Check the behavior = (1,3,5,7); foreach $i {$i *=3}