Week Four Agenda Announcements Link of the week Review week three lab assignment This week’s expected outcomes Next lab assignment Break-out problems.

Slides:



Advertisements
Similar presentations
1/12 Steven Leung Very Basic Perl Tricks A Few Ground Rules File I/O and Formatting Operators, Flow Control Statements Regular Expression Subroutines Hash.
Advertisements

A Guide to Unix Using Linux Fourth Edition
● Perl reference
Week Four Agenda Announcements Link of the week Review week three lab assignment This week’s expected outcomes Next lab assignment Break-out problems.
Introduction to Unix – CS 21 Lecture 11. Lecture Overview Shell Programming Variable Discussion Command line parameters Arithmetic Discussion Control.
CS311 – Today's class Perl – Practical Extraction Report Language. Assignment 2 discussion Lecture 071CS Operating Systems I.
CS Lecture 03 Outline Sed and awk from previous lecture Writing simple bash script Assignment 1 discussion 1CS 311 Operating SystemsLecture 03.
Linux+ Guide to Linux Certification, Second Edition
Guide To UNIX Using Linux Third Edition
Guide To UNIX Using Linux Third Edition
Shell Programming 1. Understanding Unix shell programming language: A. It has features of high-level languages. B. Convenient to do the programming. C.
Week Four Agenda Announcements Link of the week Review week three lab assignment This week’s expected outcomes Next lab assignment Break-out problems.
Sydney Opera House. Week Three Agenda Administrative Issues Link of the week Review week two lab assignment This week’s expected outcomes Next lab assignment.
Practical Extraction & Report Language PERL Joseph Beltran.
Introduction to Perl & BioPerl Dr G. P. S. Raghava Bioinformatics Centre Bioinformatics Centre IMTECH, Chandigarh Web:
1 Perl Perl basics Perl Elements Arrays and Hashes Control statements Operators OOP in Perl.
Week 7 Working with the BASH Shell. Objectives  Redirect the input and output of a command  Identify and manipulate common shell environment variables.
Week Four Agenda Announcements Link of the week Review week three lab assignment This week’s expected outcomes Next lab assignment Upcoming deadlines Lab.
An Introduction to Unix Shell Scripting
Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.
Week Five Agenda Announcements Link of the week Review week four lab assignment This week’s expected outcomes Next lab assignment Break-out problems Read.
Linux+ Guide to Linux Certification, Third Edition
1 System Administration Introduction to Scripting, Perl Session 3 – Sat 10 Nov 2007 References:  chapter 1, The Unix Programming Environment, Kernighan.
CSC 352– Unix Programming, Spring 2015 March 2015 Shell Programming (Highlights only)
Week Five Agenda Announcements Link of the week Review week four lab assignment This week’s expected outcomes Next lab assignment Reading assignments Upcoming.
Week Five Agenda Announcements Link of the week Review week four lab assignment This week’s expected outcomes Next lab assignment Break-out problems Read.
Agenda Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Review next lab assignments Break Out Problems.
Week Four Agenda Announcements Link of the week Review week three lab assignment This week’s expected outcomes Next lab assignment Break-out problems.
Week Four Agenda Announcements Link of the week Review week three lab assignment This week’s expected outcomes Next lab assignment Break-out problems.
Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
Week Two Agenda Announcements Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Next lab assignments.
Introduction to Perl Yupu Liang cbio at MSKCC
Week Two Agenda Announcements Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Next lab assignments.
Perl Language Yize Chen CS354. History Perl was designed by Larry Wall in 1987 as a text processing language Perl has revised several times and becomes.
Perl: Lecture 1 The language. What Perl is Merger of Unix tools – Very popular under UNIX – shell, sed, awk Programming language – C syntax Scripting.
Week Two Agenda Announcements Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Next lab assignments.
Introduction to Unix – CS 21
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.
©Colin Jamison 2004 Shell scripting in Linux Colin Jamison.
Chapter 11: Perl Scripting Off Larry’s Wall. In this chapter … Background Terminology Syntax Variables Control Structures File Manipulation Regular Expressions.
Copyright © 2003 ProsoftTraining. All rights reserved. Perl Fundamentals.
Sydney Opera House. Week Three Agenda Administrative Issues Link of the week Use of the Virtual Machine Review week two lab assignment This week’s expected.
Week Two Agenda Announcements Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Next lab assignments.
Introduction to Perl NICOLE VECERE. Background General Purpose Language ◦ Procedural, Functional, and Object-oriented Developed for text manipulation.
Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.
Department of Electrical and Computer Engineering Introduction to Perl By Hector M Lugo-Cordero August 26, 2008.
Sydney Opera House. Week Three Agenda Administrative Issues Link of the week Use of the Virtual Machine Review week two lab assignment This week’s expected.
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.
Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems Upcoming.
Week Five Agenda Link of the week Review week four lab assignment This week’s expected outcomes Next lab assignment Break-out problems Upcoming deadlines.
Week Four Agenda Link of the week Review week three lab assignment This week’s expected outcomes Next lab assignment Break-out problems Upcoming deadlines.
Week Four Agenda Announcements Link of the week Review week three lab assignment This week’s expected outcomes Next lab assignment Break-out problems.
Scripting Languages ● Perl, Python, Unix Shell, VB, JavaScript, etc. ● Glue Languages. ● Typeless. ● Interchangeable Code and Data. ● Interpreted vs. Compiled.
PERL By C. Shing ITEC Dept Radford University. Objectives Understand the history Understand constants and variables Understand operators Understand control.
Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Moving around in UNIX Break-Out Problems Upcoming.
2000 Copyrights, Danielle S. Lahmani Foreach example = ( 3, 5, 7, 9) foreach $one ) { $one*=3; } is now (9,15,21,27)
The Scripting Programming Language
Dept. of Animal Breeding and Genetics Programming basics & introduction to PERL Mats Pettersson.
Perl Subroutines User Input Perl on linux Forks and Pipes.
Linux Administration Working with the BASH Shell.
Week Four Agenda Announcements Link of the week Review week three lab assignment This week’s expected outcomes Next lab assignment Break-out problems.
Week Three Agenda Link of the Week Review Week Two Information
Agenda Bash Shell Scripting – Part II Logic statements Loop statements
CSC 352– Unix Programming, Fall 2012
Sydney Opera House.
Week Five Agenda Announcements Link of the week
Week Three Agenda Link of the Week Review Week Two Information
CSC 352– Unix Programming, Fall, 2011
Presentation transcript:

Week Four Agenda Announcements Link of the week Review week three lab assignment This week’s expected outcomes Next lab assignment Break-out problems Upcoming deadlines Lab assistance, questions and answers

Link of the Week Object Code and-object-codehttp://freedom-to-tinker.com/blog/felten/source-code- and-object-code What is object code? Object File Format What is Executable and Linking Format?

Link of the Week

Review Week Three Lab Assignment Script Comments Scripts should contain comments to help the user understand what the script is doing or not doing. The functionality comments should be detailed enough to give the user a good overall understanding about the script. Execution contingencies: Script functionality: Script limitations: Input data:

Review Week Three Lab Assignment A process associates a number with each file that it has opened. This number is called a file descriptor. When you log in, your first process has the following three open files connected to your terminal. Standard Input (stdin) : File descriptor 0 is open for reading. < really means <0 Standard Output (stdout): File descriptor 1 is open for writing. > really means 1> Standard Error (stderr): File descriptor 2 is open reading. >> really means 1>>

Review Week Three Lab Assignment Perl is a simple language that compiles and executes like a shell or batch type file. Perl doesn’t impose special growth limitations on an array or data strings Perl is a composite of C, AWK, and Basic. Perl was originally developed to manipulate text information.

Review Week Three Lab Assignment Perl’s capabilities range from - System administration - Web development - Network programming - GUI development Perl’s major features are -Procedural Programming makes use of simple sequential steps, routines, subroutines, and methods. -Object Oriented Programming (OOP) makes use of “objects”. The key elements of are inheritance, modularity, polymorphism, and encapsulation.

Review Week Three Lab Assignment Perl and Shell Similarities Perl ~ Shell $# Perl $ARGV[0] ~ Shell $1 Perl $ARGV[1] ~ Shell $2 Perl ~ Shell if [ $# != 2] All Perl statements are terminated with a “;” Perl exit 0 is returned if execution was successful. Perl exit 1 is returned if execution fails.

Review Week Three Lab Assignment Perl syntax $? - this variable contains the return value # - precedes a comment statement in Perl \n - new line syntax “ …” $strexp = “This text is considered as a string”; ‘ …’ $charexp = ‘a’; ` …` $cmdexp = `ls – array containing command line arguments $_ - default implied scalar

Review Week Three Lab Assignment There are two types of relational operators. One class operates on numeric values, the other on string values. Relational operators Numeric String Meaning > gt Greater than >= ge Greater than or equal < lt Less than <=le Less than or equal

Review Week Three Lab Assignment Equality Operators Numeric String Meaning == eq Equal to != ne Not equal to  cmp Comparison, sign results -1 if the left operand is less 0 If both operands equal 1 If the left operand is greater

Review Week Three Lab Assignment Commands cal –y (display a calandar for the year) cal –j 2010 (display Julian dates) cal –m 2010 (display Monday first day) cal –s 2010 (display Sunday first day) cal (display September 2009 month)

Week Four Expected Outcomes Learning Outcomes Write Perl scripts, including variables, control flow, and regular expression syntax

Next Lab Assignment Perl is designed to - Process text data - Perform pattern matching (regular expressions) - Utilize string handling tasks Perl is available on many platforms - UNIX - Linux - HP-UX

Next Lab Assignment Perl utilizes two types of categories - Singular variables that represent a single-value. The variable prefix symbol for a scalar is the $. Example: $scalar_variable_name - Plural variables are ones that contain multiple-values. Arrays and hashes are two multi-valued variables. Example: %hash_variable_name

Next Lab Assignment Perl data types $answer = 42; (an integer) $pi = ; (a “real” number) $animal = “horse”; (string) $statement = “I exercise my $animal”; (string with interpolation) $amount = ‘It cost me $5.00’; (string without interpolation) $cwd = `pwd`; (string output from a command)

Next Lab Assignment Definition: An array is an ordered list of scalars, accessed by the scalar’s position in the = (“car”, “mower”, = (“Will”, “Karim”, “Asma”, “Jay”); $count Demonstrate Execute week_four.pl script

Next Lab Assignment Open Statement The open function can be used to create file handles for different purposes (input, output, piping), you need to be able to specify which behavior you want.

Next Lab Assignment open function # Input file open(file_handler, “file_name”) # Input file open(file_handler, “<file_name”) # Output file open (file_handler, “>file_name”) # Append file open (file_handler, “>>file_name”)

Next Lab Assignment Definition: Filehandle is utilized for both input and output files. Most file names are cryptic and are meaningless to programmers. The purpose of a filehandle is to help the programmer remember a simple file name throughout a program. A filehandle is a name given for a file, device, socket, or pipe. Filehandle command line format: open(filehandle, file name, permissions, chmod); Example: open($FH,$file_name);

Next Lab Assignment List Processing = (6 - 4, 4 * 4, 8 / 2, 9 - 8); while ( … ) { … }

Next Lab Assignment For loop Example: for (counter = 0; counter < 10; counter++) { … } Three expressions are contained in a for loop: 1.Set initial state of the loop variable 2.Condition test the loop variable 3.Modify the state of the loop variable

Next Lab Assignment Perl Subroutines Is a named piece of program that can be invoked from elsewhere in the program in order to accomplish some sub-goal of the program. Subroutine Format sub NAME BLOCK Example: sub subroutine_name { print "Hello, ITEC 400 class. \n"; }

Next Lab Assignment my Operator Initially, Perl observes the enclosed block to see what variable(s) are declared in the same block with the “my” declaration. The variable is lexically scoped and doesn’t exist in any other package. It exists only in that lexical scope. This operator declares one or more variables to exist only within the inner most enclosed block. Example: sub subroutine_name { my $name = shift; print "Hello, my name is Gail. \n"; }

Next Lab Assignment Shift Function The shift operator takes the next option in the active array. Example: sub subroutine_name { # Use the presently referenced array. my $name = shift; print "Hello, my name is $name. \n"; } use Declaration The use declaration loads in a module and imports subroutines and variables into the current package from the named module.

Next Lab Assignment use Declaration Example: # All possible restrictions are assumed. use strict; # Subroutine correct_msg sub correct_msg{ print_msg(" Good message. \n"); } There are three possible options to be strict about. They are vars, refs, and subs. Strict without options is the safest, but most restrictive mode to operate.

Next Lab Assignment Foreach loop Example: foreach VAR (List) { … } Demonstrate Execute read_list.pl script

Next Lab Assignment Foreach loop = ('Larry', 'Curly', 'Moe'); foreach { print $_; } Demonstrate Execute sum_list.pl script Execute arry_sort.pl script

Next lab assignment Perl Program Statement #!/usr/bin/perl #!/usr/bin/perl –w Print continuation statement print "error: incorrect number of arguments", "\n", "usage: intlist a b (where a < b)", "\n";

Next lab assignment Demonstrate Lab Assignment 4-1 Execute linenum.pl and intlist.pl scripts.

Break-out problems 1.$strexp = “This text is considered as a string”; 2.$intexp = 10; 3.$floatptexp = 2.54; 4.$charexp = ‘a’; 5.$cmdexp = `ls –l`; 6.$argexp = (“two”, “four”, “six”); = (“Jackie”, “Vicki”, “Alex”); 8.$arrayexp[0] = “new value”; 9.$a = $b + 5; 10.$container 11.($map{blue}, $map{orange}, $map{jade}) = (0xff0000, 0x00ff00, 0x0000ff0);

Next Lab Assignment Programming Perl text book reading Chapter One Chapter Two Chapter Three

Next Lab Assignment The following Perl scripts have been copied to the /tmp system directory for you to copy and use personally: substr.pl output_msg.pl sub_arg_pass.pl read_list.pl sum_list.pl arry_sort.pl

Upcoming deadlines Lab Assignment 3-1, Advanced Scripting, due January 31, Lab Assignment 4-1, Simple Perl Exercise, due February 7, Read Module Three listed under the course Web site.

Questions and answers Questions Comments Concerns After class, I will help students with their scripts.