Karan Thaker CS 265 Section 001

Slides:



Advertisements
Similar presentations
CIS 240 Introduction to UNIX Instructor: Sue Sampson.
Advertisements

A Guide to Unix Using Linux Fourth Edition
Introduction to Unix – CS 21 Lecture 11. Lecture Overview Shell Programming Variable Discussion Command line parameters Arithmetic Discussion Control.
Programming Perls* Objective: To introduce students to the perl language. –Perl is a language for getting your job done. –Making Easy Things Easy & Hard.
Introduction to Perl Bioinformatics. What is Perl? Practical Extraction and Report Language A scripting language Components an interpreter scripts: text.
CSET4100 – Fall 2009 Perl Introduction Scalar Data, Operators & Control Blocks Acknowledgements: Slides adapted from NYU Computer Science course on UNIX.
CS311 – Today's class Perl – Practical Extraction Report Language. Assignment 2 discussion Lecture 071CS Operating Systems I.
Shell Programming Software Tools. Slide 2 Shells l A shell can be used in one of two ways: n A command interpreter, used interactively n A programming.
CS 497C – Introduction to UNIX Lecture 33: - Shell Programming Chin-Chih Chang
Scalar Variables Start the file with: #! /usr/bin/perl –w No spaces or newlines before the the #! “#!” is sometimes called a “shebang”. It is a signal.
CS 330 Programming Languages 10 / 11 / 2007 Instructor: Michael Eckmann.
More on Numerical Computation CS-2301 B-term More on Numerical Computation CS-2301, System Programming for Non-majors (Slides include materials from.
LING 388: Language and Computers Sandiway Fong Lecture 3: 8/28.
Perl Lecture #1 Scripting Languages Fall Perl Practical Extraction and Report Language -created by Larry Wall -- mid – 1980’s –needed a quick language.
Operators. Perl has MANY operators. –Covered in Chapter 3 of Prog.Perl Most operators have numeric and string version –remember Perl will convert variable.
Guide To UNIX Using Linux Third Edition
The Data Element. 2 Data type: A description of the set of values and the basic set of operations that can be applied to values of the type. Strong typing:
Practical Extraction & Report Language PERL Joseph Beltran.
Print 'Hello world.'; Tren Griffith. Outline:  Perl introduction  Scalar Data  Variables  Operators  Control Structures  Input  Lists and Arrays.
Perl By Gabe and Ted. History Perl was created by Larry Wall while working at NASA’s Jet Propulsion Labs. Larry Wall also created patch which is in widespread.
1 System Administration Introduction to Scripting, Perl Session 3 – Sat 10 Nov 2007 References:  chapter 1, The Unix Programming Environment, Kernighan.
Introduction to PHP A user navigates in her browser to a page that ends with a.php extension The request is sent to a web server, which directs the request.
Perl Practical(?)‏ Extraction and Report Language.
CS 330 Programming Languages 10 / 07 / 2008 Instructor: Michael Eckmann.
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.
Chapter 9: Perl Programming Practical Extraction and Report Language Some materials are taken from Sams Teach Yourself Perl 5 in 21 Days, Second Edition.
Prof. Alfred J Bird, Ph.D., NBCT Office – McCormick 3rd floor 607 Office Hours – Tuesday and.
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.
CS 105 Perl: Basic I/O, Context, Strings, Lists Nathan Clement January 22, 2014.
Introduction to Perl October 4, 2004 Class Meeting 7 * Notes on Perl by Lenwood Heath, Virginia Tech © 2004.
Topic 2: Working with scalars CSE2395/CSE3395 Perl Programming Learning Perl 3rd edition chapter 2, pages 19-38, Programming Perl 3rd edition chapter.
Introduction to Perl NICOLE VECERE. Background General Purpose Language ◦ Procedural, Functional, and Object-oriented Developed for text manipulation.
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.
Basic Variables & Operators Web Programming1. Review: Perl Basics Syntax ► Comments: start with # (ignored by Perl) ► Statements: ends with ; (performed.
Shell script – part 2 CS 302. Special shell variable $0.. $9  Positional parameters or command line arguments  For example, a script myscript take 2.
Scott Marino MSMIS Kean University MSAS5104 Programming with Data Structures and Algorithms Week 1 Scott Marino.
PERL By C. Shing ITEC Dept Radford University. Objectives Understand the history Understand constants and variables Understand operators Understand control.
Perl for Bioinformatics Part 2 Stuart Brown NYU School of Medicine.
File Handle and conditional Lecture 2. File Handling The Files associated with Perl are often text files: e.g. text1.txt Files need to be “opened for.
Operators. Perl has MANY operators. –Covered in Chapter 3 of Camel –perldoc perlop Many operators have numeric and string version –remember Perl will.
Chapter 17 Arrays Perl to denote an array, for = (10, 20, 30, 50); Array subscripts are number from 0. Array elements require scalar.
© 2016 Pearson Education, Ltd. All rights reserved.
Perl Programming Language Design and Implementation (4th Edition)
Data Types and Structures
Chapter 5 - Control Structures: Part 2
An Introduction to Perl – Part I
Python is a general-purpose interpreted, interactive, object-oriented, and high-level programming language. It was created by Guido van Rossum during.
JavaScript: Functions.
Perl for Bioinformatics
Topics Introduction to File Input and Output
Control Structures: if Conditional
Introduction to Programming
An Introduction to Perl
Basic Input/Output Web Programming.
Control Structures: for & while Loops
Programming Perls* Objective: To introduce students to the perl language. Perl is a language for getting your job done. Making Easy Things Easy & Hard.
Perl I/O Learning Objectives:
Lists in Python Outputting lists.
Topics Introduction to File Input and Output
The Data Element.
Assignment #3 Programming Language, Spring 2003
The Selection Structure
Perl Control Flow Learning Objectives:
The Data Element.
Topics Introduction to File Input and Output
CIS 136 Building Mobile Apps
DATA TYPES AND OPERATIONS
INTRODUCTION to PERL PART 1.
Class code for pythonroom.com cchsp2cs
This is an introduction to JavaScript using the examples found at the CIS17 website. In previous examples I specified language = Javascript, instead of.
Presentation transcript:

Karan Thaker CS 265 Section 001 Introduction to Perl Karan Thaker CS 265 Section 001

Topics Covered What is Perl? Scalar Data Variables and Operators If-else and while control structures Standard input Lists and Arrays

What is Perl? Practical Extraction and Reporting Language Very widely used SCRIPTING language Designed for text processing “There’s more than one way to do it”

Scalar Data Simplest type of data that PERL manipulates Either a number or string Can be acted upon with operators (like plus or concatenate) Integers and floats have essentially the same format “undef” – special value assigned to all variables Zero when assigned to numbers NULL when applied to strings

Variables and Operators Naming: Begins with “$” followed by the identifier For example, $karan, $drexel, $computer Any scalar variable holds a SINGLE scalar value Operators Assignment = Arithmetic + , - , * , / String -string concatenation (a dot), x –string repetition Numeric comparison == , != , < , > , <= , >= String comparison eq, ne, lt, gt, le, ge

Control Structures if - else while Similar to C++ Curly braces required if - else while if(...) { ... }else ( } if(...) { ... } while(...) { ... }

Standard Input $line =<STDIN>; Reads a full line from input and stores it in variable $line $line=<STDIN>; if($line eq "\n"){ print "This was an empty line.\n"; } else { print "This line was not empty.\n"; } A line of input is read and one of the two strings is printed out while(defined($line=<STDIN>)){ print “This line was: $line \n”; } Input is displayed in output, and loop stops when end-of-file is reached.

Lists and Arrays Reading into a list Accessing list elements (1,2,3,4,5,6,7,8,9,10) # list consisting of numbers 1 to 10 (1..10) # same list created by the range # operator ($a ..$b) # the range determined by current values of $a and $b Reading into a list Accessing list elements @numbers=(1..100); print $numbers[0]; # prints 1 print $numbers[10]; # prints 11 while(<>){ $lines[$index]=$_ ; $index=$index+1; } print $#lines+1; print @lines; List Assignment ($fred, $barney)=($barney, $fred); # values are swapped @numbers=(1..10); # list (1..10) is stored inside an array

Thank you