Interpolation Variable Interpolation, Backslash Interpolation.

Slides:



Advertisements
Similar presentations
A primer on Perl programming First structures (with examples)
Advertisements

Chapter 25 Perl and CGI (Common Gateway Interface)
This Time Whitespace and Input/Output revisited The Programming cycle Boolean Operators The “if” control structure LAB –Write a program that takes an integer.
Scalar Data Types and Basic I/O
CS0007: Introduction to Computer Programming Console Output, Variables, Literals, and Introduction to Type.
Bioinformatics is … - the use of computers and information technology to assist biological studies - a multi-dimensional and multi-lingual discipline Chapters.
COMP234 Perl Printing Special Quotes File Handling.
CSET4100 – Fall 2009 Perl Introduction Scalar Data, Operators & Control Blocks Acknowledgements: Slides adapted from NYU Computer Science course on UNIX.
Programming and Perl for Bioinformatics Part I. A Taste of Perl: print a message perltaste.pl: Greet the entire world. #!/usr/bin/perl #greet the entire.
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.
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.
ISBN Chapter 6 Data Types Character Strings Pattern Matching.
Introduction to Perl. How to run perl Perl is an interpreted language. This means you run it through an interpreter, not a compiler. Your program/script.
More Regular Expressions. List/Scalar Context for m// Last week, we said that m// returns ‘true’ or ‘false’ in scalar context. (really, 1 or 0). In list.
1ex.1 Perl Programming for Biology Exercise 1 The Bioinformatics Unit G.S. Wise Faculty of Life Science Tel Aviv University, Israel March 2009 Eyal Privman.
Operators. Perl has MANY operators. –Covered in Chapter 3 of Prog.Perl Most operators have numeric and string version –remember Perl will convert variable.
Regular Expressions. What are regular expressions? A means of searching, matching, and replacing substrings within strings. Very powerful (Potentially)
Writing Tcl Scripts Outline Goal Reading Syntax Data Types
CS 898N – Advanced World Wide Web Technologies Lecture 7: PERL Chin-Chih Chang
20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 8: Perl Basics Fundamentals of Web Programming.
PHP Workshop ‹#› PHP: The Basics. PHP Workshop ‹#› What is it? PHP is a scripting language commonly used on web servers. –Stands for “PHP: Hypertext Preprocessor”
Regular Expression A regular expression is a template that either matches or doesn’t match a given string.
Computer Programming for Biologists Class 2 Oct 31 st, 2014 Karsten Hokamp
1 An Introduction to Perl Part 1 CSC8304 – Computing Environments for Bioinformatics - Lecture 7.
C-Language Keywords(C99)
Introduction to Java Thanks to Dan Lunney (SHS). Java Basics File names The “main” method Output to screen Escape Sequence – Special Characters format()
Print 'Hello world.'; Tren Griffith. Outline:  Perl introduction  Scalar Data  Variables  Operators  Control Structures  Input  Lists and Arrays.
Perl Practical(?)‏ Extraction and Report Language.
COMP519: Web Programming Autumn 2010 Perl Tutorial: The very beginning  A basic Perl Program The first line Comments and statements Simple printing 
 Character set is a set of valid characters that a language can recognise.  A character represents any letter, digit or any other sign  Java uses the.
Data TypestMyn1 Data Types The type of a variable is not set by the programmer; rather, it is decided at runtime by PHP depending on the context in which.
CS346 Javascript -3 Module 3 JavaScript Variables.
Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
1 PHP Intro PHP Strings After this lecture, you should be able to: Manipulate and Output PHP Strings: Manipulate and Output PHP Strings: Single- or Double-quoted.
_______________________________________________________________________________________________________________ PHP Bible, 2 nd Edition1  Wiley and the.
1 Introduction to Perl CIS*2450 Advanced Programming Techniques.
Introduction to Perl “Practical Extraction and Report Language” “Pathologically Eclectic Rubbish Lister”
CS 330 Programming Languages 10 / 02 / 2007 Instructor: Michael Eckmann.
Perl Chapter 5 Hashes. Outside of world of Perl, know as associative arrays Also called hash tables Perl one of few languages that has hashes built-in.
CS 105 Perl: Basic I/O, Context, Strings, Lists Nathan Clement January 22, 2014.
LING/C SC/PSYC 438/538 Lecture 8 Sandiway Fong. Adminstrivia Homework 4 not yet graded …
Perl COEN 351  Thomas Schwarz, S.J Perl Scripting Language Developed by Larry Wall 1987 to speed up system administration tasks. Design principles.
C++ Basics Tutorial 5 Constants. Topics Covered Literal Constants Defined Constants Declared Constants.
CPTG286K Programming - Perl Chapter 1: A Stroll Through Perl Instructor: Denny Lin.
A Few More Functions. One more quoting operator qw// Takes a space separated sequence of words, and returns a list of single-quoted words. –no interpolation.
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.
Department of Electrical and Computer Engineering Introduction to Perl By Hector M Lugo-Cordero August 26, 2008.
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.
PHP Workshop ‹#› أطلق إبداعك 2 أطلق إبداعك 2 مدرس معتمد من مركز زووم PHP: The Basics.
Chapter 2 print / println String Literals Escape Characters Variables / data types.
© 2007 Lawrenceville Press Slide 1 Chapter 3 Classes and Objects 1. How is a class different from an object?
CSCI 1100/1202 January 14, Abstraction An abstraction hides (or ignores) the right details at the right time An object is abstract in that we don't.
Perl for Bioinformatics Part 2 Stuart Brown NYU School of Medicine.
Chapter 2 1.What is the difference between print / println 2.What are String Literals 3.What are the Escape Characters for backslash, double quotataions,
Escape sequence Certain characters, preceded by a backslash ( \ ), are known as escape sequences They are used to display certain characters, or as display.
LING/C SC/PSYC 438/538 Online Lecture 7 Sandiway Fong.
The Scripting Programming Language
Dept. of Animal Breeding and Genetics Programming basics & introduction to PERL Mats Pettersson.
Introduction to Programming the WWW I CMSC Winter 2003 Lecture 17.
Chapter 9 – String Manipulation
More about comments Review Single Line Comments The # sign is for comments. A comment is a line of text that Python won’t try to run as code. Its just.
Topic Pre-processor cout To output a message.
LING/C SC/PSYC 438/538 Lecture 4 Sandiway Fong.
Programming in Perl Introduction
Control Structures: if Conditional
The backslash is used to escape characters that are used in Python
“If you can’t write it down in English, you can’t code it.”
Nate Brunelle Today: Strings, Type Casting
Presentation transcript:

Interpolation Variable Interpolation, Backslash Interpolation

Interpolation Sometimes called “substitution” –In Perl, “Substitution” means something else Interpolation = replacing symbol/variable with its meaning within a string Two kinds of interpolation – variable and backslash Done *only* in double-quoted strings, not single-quoted strings.

Backslash interpolation aka: character interpolation, character escapes, escape sequences. When any of these sequences are found inside a double – quoted string, they’re interpolated Listed on page 61 of Prog. Perl. Most common: “\n”, “\t”

Translation Escapes pg 61, table 2-2 of Prog.Perl \u – next character is uppercase \l – next character is lowercase \U – all characters until \E are uppercase \L – all characters until \E are lowercase \Q – all characters until \E are backslashed \E – end \U, \L, or \Q

Variable Interpolation variables found within “ ” are interpolated. ‘ ’ strings are NOT searched for interpolation $foo = “hello”; $bar = “$foo world” –$bar gets value: “hello world” $bar2 = ‘$foo world’ –$bar2 gets value: ‘$foo world’

What can interpolate? Scalars, arrays, slices of arrays, slices of hash –NOT entire hashes Arrays (and slices) will print out each member of array separated by a space: = (1, 3, 5, 7) –print “The first 4 odd numbers –outputs: The first 4 odd numbers are Change separation sequence via $” variable