Prof. Alfred J Bird, Ph.D., NBCT Office – McCormick 3rd floor 607.

Slides:



Advertisements
Similar presentations
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.
Advertisements

Introduction to C++ Programming. A Simple Program: Print a Line of Text // My First C++ Program #include int main( ) { cout
Understanding bash Prof. Chris GauthierDickey COMP 2400, Fall 2008.
1 September 6, 2005CS150 Introduction to Computer Science I What Actions Do We Have Part 1 CS150 Introduction to Computer Science I.
COS 381 Day 22. Agenda Questions?? Resources Source Code Available for examples in Text Book in Blackboard
Shell Programming 1. Understanding Unix shell programming language: A. It has features of high-level languages. B. Convenient to do the programming. C.
Computing with Strings CSC 161: The Art of Programming Prof. Henry Kautz 9/16/2009.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 25 – Perl and CGI (Common Gateway Interface) Outline 25.1 Introduction 25.2 Perl 25.3 String Processing.
Prof. Alfred J Bird, Ph.D., NBCT Office – McCormick 3rd floor 607 Office Hours – Tuesday and.
Prof. Alfred J Bird, Ph.D., NBCT Office – Wheatly 2nd floor Office Hours – MW 3:00PM to 4:00PM.
August Chapter 1 - Essential PHP spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science and Technology.
Chapter 4 MATLAB Programming Combining Loops and Logic Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Introduction to Functions Intro to Computer Science CS1510 Dr. Sarah Diesburg.
Prof. Alfred J Bird, Ph.D., NBCT Office – Wheatly 2nd floor Office Hours – MW 3:00PM.
Hello World 2 What does all that mean?.
Prof. Alfred J Bird, Ph.D., NBCT Office – McCormack 3rd floor 607.
Shell Scripting Todd Kelley CST8207 – Todd Kelley1.
Subroutines and Files Bioinformatics Ellen Walker Hiram College.
CIS 218 Advanced UNIX1 CIS 218 – Advanced UNIX (g)awk.
CST8177 bash Scripting Chapters 13 and 14 in Quigley's "UNIX Shells by Example"
Prof. Alfred J Bird, Ph.D., NBCT Office – McCormick 3rd floor 607 Office Hours – Tuesday and.
Chapter 9 1 Chapter 9 – Part 1 l Overview of Streams and File I/O l Text File I/O l Binary File I/O l File Objects and File Names Streams and File I/O.
Prof. Alfred J Bird, Ph.D., NBCT Door Code for IT441 Students – * Office – Wheatly.
Prof. Alfred J Bird, Ph.D., NBCT Door Code: * Office – McCormick 3rd floor 607 Office.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
File I/O ifstreams and ofstreams Sections 11.1 &
Prof. Alfred J Bird, Ph.D., NBCT -bird.wikispaces.umb.edu/ Office – McCormick 3rd floor.
+ Introduction to Class IST210 Class Lecture. + Course Objectives Understand the importance of data, databases, and database management Design and implement.
1 Perl Syntax: control structures Learning Perl, Schwartz.
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
File I/O 1 ifstreams and ofstreams Sections 11.1 & 11.2.
Prof. Alfred J Bird, Ph.D., NBCT Door Code for IT441 Students.
Prof. Alfred J Bird, Ph.D., NBCT Office – McCormick 3rd floor 607 Office Hours – Tuesday and.
(A Very Short) Introduction to Shell Scripts CSCI N321 – System and Network Administration Copyright © 2000, 2003 by Scott Orr and the Trustees of Indiana.
Scis.regis.edu ● CS-361: Control Structures Week 6 Dr. Jesús Borrego Lead Faculty, COS Regis University 1.
Shell Programming Learning Objectives: 1. To understand the some basic utilities of UNIX File 2. To compare UNIX shell and popular shell 3. To learn the.
©Colin Jamison 2004 Shell scripting in Linux Colin Jamison.
Xuan Guo Chapter 5 The Bourne Shell Graham Glass and King Ables, UNIX for Programmers and Users, Third Edition, Pearson Prentice Hall, Notes by Michael.
Prof. Alfred J Bird, Ph.D., NBCT Door Code for IT441 Students.
1 Lecture 9 Shell Programming – Command substitution Regular expressions and grep Use of exit, for loop and expr commands COP 3353 Introduction to UNIX.
Lecture 26: Reusable Methods: Enviable Sloth. Creating Function M-files User defined functions are stored as M- files To use them, they must be in the.
Prof. Alfred J Bird, Ph.D., NBCT Office – McCormick 3rd floor 607 Office Hours – Tuesday and.
Introduction to Perl. What is Perl Perl is an interpreted language. This means you run it through an interpreter, not a compiler. Similar to shell script.
Prof. Alfred J Bird, Ph.D., NBCT Office – McCormick 3rd floor 607.
More Shell Programming. Slide 2 Control Flow  The shell allows several control flow statements:  if  while  for.
Prof. Alfred J Bird, Ph.D., NBCT Door Code for IT441 Students.
Trinity College Dublin, The University of Dublin GE3M25: Computer Programming for Biologists Python, Class 2 Karsten Hokamp, PhD Genetics TCD, 17/11/2015.
Assigning Values 1. $ set One Two Three [Enter] $echo $1 $2 $3 [Enter] 2. $set `date` [Enter] $echo $1 $2 $3 [Enter] 3. $echo $1 $2 $3 $4 $5 $6 [Enter]
IT443 – Network Security Administration Week 2 – Wireshark Instructor: Alfred J Bird, Ph.D., NBCT
1 Project 7: Looping. Project 7 For this project you will produce two Java programs. The requirements for each program will be described separately on.
02/03/ Strings Left, Right and Trim. 202/03/2016 Learning Objectives Explain what the Left, Right and Trim functions do.
Perl for Bioinformatics Part 2 Stuart Brown NYU School of Medicine.
Prof. Alfred J Bird, Ph.D., NBCT Office – McCormick 3nd floor, room 607 Office Hours –Tuesday.
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.
Perl: Practical Extraction & Reporting Language RL Schwartz, Learning Perl, RL Schwartz & L Wall, Programming Perl, O’Reilly & Associates.
Perl Subroutines User Input Perl on linux Forks and Pipes.
Linux Administration Working with the BASH Shell.
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.
Prof. Alfred J Bird, Ph.D., NBCT Office – Science 3rd floor – S Office Hours – Monday and Thursday.
University of Kansas Department of Electrical Engineering and Computer Science Dr. Susan Gauch April 21, 2005 I T T C Introduction to Web Technologies.
Math Expression Evaluation With RegEx and Finite State Machines.
Prof. Alfred J Bird, Ph.D., NBCT Office – McCormick 3rd floor 607 Office Hours – Monday 3:00 to 4:00 and.
Prof. Alfred J Bird, Ph.D., NBCT Office – McCormick 3rd floor 607.
What Actions Do We Have Part 1
IT441 Network Services Administration
IT441 Network Services Administration
Shell Scripting March 1st, 2004 Class Meeting 7.
Hello World 2 What does all that mean?.
LING 408/508: Computational Techniques for Linguists
Introduction to Computer Science
Presentation transcript:

Prof. Alfred J Bird, Ph.D., NBCT Office – McCormick 3rd floor 607 Office Hours – Tuesday and Thursday 4:00PM to 5:15PM

 What is a pipe?  Why do we use pipes?  In Perl we implement pipes using the OPEN statement  open (FH, -|, ‘perl sort2.pl gettysburg.txt’);  What will this statement do?  It will start a perl program sort2.pl using the file gettysburg.txt and send the output from sort2.pl into our program under the filehandle.

 -| brings the output of the other program into our program via the filehandle  |- takes the output of our program and sends it to the other program using the file handle and a print statement

 Before we do anything we often would like to know the status of the file or directory we are working with.  We can do this with the following type of test  if (flag “somefile.dat”) {action} or  if (flag $somefile) {action}

 -e true if the file exists  -ftrue if a plain file – not a directory  -dtrue if file is a directory  -ztrue if file has zero size  -strue if file has nonzero size -- returns size  -rtrue if file is readable by you  -wtrue if file is writeable by you  -xtrue if file is executable by you  -otrue if file is owned by you This is table 8-1 on page 201 in the textbook

 Write a simple program to: Read in the name of a file from the keyboard Check if the file exists. Check to see if it is a directory Check to see what permissions you have on this file Print out appropriate information to the screen

 Write a simple program to: Read in the name of a file from the keyboard Check if the file exists. Check to see if it is a directory Check to see what permissions you have on this file Print out appropriate information to the screen  See filetesting.pl in my home directory

 Remember strings are the basic data type in Perl  We have already learned one way to process a string.  We can use a regex (a regular expression)  Remember how the characters in a string are counted  The first (left most) character is 0  The last (right most) character is -1  There is another way to process strings in Perl  Perl has many built-in functions to process strings.

 Some string functions implemented in Perl  length(string)  Use this function to determine the length of the string.  index(string, substring)  Use this function to determine the 0-based location of the substring in the string. If substring is not found it returns a -1.  rindex(string, substring)  Similar to index() but starts from the right-most end.  substr(string, starting-index, length)  This function returns a substring of length number of characters starting from starting-index.

 Copy string.txt from my home directory.  Write a small program that will:  Calculate the number of characters in the string using the string function length().  Find the location of a substring entered from the keyboard.  Strip out a substring of a given length starting at a given position where the length and position are entered from the keyboard.  Print out the results to the screen.

 Copy string.txt from my home directory.  Write a small program that will:  Calculate the number of characters in the string using the string function length().  Find the location of a substring entered from the keyboard.  Strip out a substring of a given length starting at a given position where the length and position are entered from the keyboard.  Print out the results to the screen. See strfunctest.pl in my home directory for a solution

 Read pages 196 to 205 in the textbook.  Study and try to understand the program filetest.pl on pages See if you can enter it and make it work.  Read pages in the textbook.