Advanced Web Design. Unit 8 The Basics of Perl

Size: px
Start display at page:

Download "Advanced Web Design. Unit 8 The Basics of Perl"

Transcription

1 Advanced Web Design Unit 8 The Basics of Perl Eduoncloud.com Page 1

2 Origins and Uses of Perl Perl was developed in 1987 by Larry Wall. What is perl Practical Extraction and Report Language Goal: to expand on the text-processing features of awk. Why perl: Interpreted Language Optimized for String Manipulation and File I/O Full support for Regular Expressions. Widely used for CGI scripting Freely available Basic Syntax Statements end with semicolon ; Comments start with # Only single line comments Variables You don t have to declare a variable before you access it You don't have to declare a variable's type Eduoncloud.com Page 2

3 What are the benefits of perl? What are the basic datatypes in perl What are the three categories of perl variables? Give example for each Benefits of perl support for communications using sockets support for object-oriented programming powerful text pattern-matching capabilities Portability: Perl code that doesn't use system specific features can be run on any platform Basic Data-types. Three categories of variables in Perl: 1. scalar variables - begin with $. - Scalar variables can store numbers character strings references (addresses) 2. vector (Array) variables - = (1, 2, = ('Larry', 'Curly', 'Moe'); 3. hash (Associative Array) variables - begins with %. %myhash = ( "name" => "Larry", "phone" => " " ); Eduoncloud.com Page 3

4 how can a perl variable acts as string and number? --06 Perl is a weakly typed language, meaning that a "variable" could hold many different forms of data. perl variable as number Perl uses double-precision floating point values for calculation. Example: $x =10.7 #floating-point values $a =1000 #integer values Perl also accepts string literal as a number for example: $s = "2000"; # similar to $s = 2000; perl variable as string Perl defines string as a sequence of characters. $str = "this is a string in Perl". Constants: Numeric Literals All numeric values are represented internally as doubleprecision floating point values. Literal numbers are integers or floating point values. Integers are strings of digits Integers can be written in hexadecimal by preceding them with 0x Floating point values can have decimal points and/or exponents: # integer # negative integer # floating point Eduoncloud.com Page 4

5 6.02E23 # scientific notation 0xffff # hexadecimal 0377 # octal String Literals Quoting Strings 1. Strings enclosed in single quotes : Everything is interpreted literally Can t include: escape sequences such as \n. Include: a single quote \'. single quotes can be replaced by other delimiter using "q" q$i don't want to go, I can't go, I won't go!$ q<i don't want to go, I can't go, I won't go!> 2. Double-quoted string can include special characters (such as \n). A double quote can be embedded by preceding it with a backslash "\"Aha!\", he said." A different delimited can be used proceeding with qq. qq@"why, I never!", said she@ A null string is written as ' ' or " ". 3. With ` (backtick) The text is executed as a separate process, and the output of the command is returned as the value of the string Eduoncloud.com Page 5

6 Quote and Quote-like Operators Customary Generic Meaning Interpolates '' q Literal no "" qq Literal yes `` qx Command yes* qw Word list no // m Pattern match yes* qr Pattern yes* s Substitution yes* tr Transliteration no y Transliteration no <<EOF here-doc yes* * unless the delimiter is ''. Scalar Variables: Rules The names of scalar variable all begin with $ and then continue with a letter, followed by letters, digits and/or underscores. Variable names are case sensitive, so $FRIZZY, $Frizzy and $frizzy are three different names. Convention: programmer names in Perl should not use uppercase. Interpolation: If variables names are included in double- quoted string, the variable names are Interpolated ( replaced by their values). Example Eduoncloud.com Page 6

7 $age = 47; $mystring = "Jack is $age years old "; $mystring has the value: "Jack is 47 years old" Declaring Scalar Variables rarely declared explicitly; done implicitly when a value is assigned to the variable. Scalar variables that have not been assigned a value by the program that the value undef, with a numerical value of 0 and a string value of "". Implicit Variables Perl has several predefined, or implicit, variables, whose names begin with $. $_ Set in many situations such as reading from a file or in a foreach loop. $0 Name of the file currently being executed. $] Version of Perl Contains the parameters passed to a subroutine. Contains the command line arguments passed to the program. Eduoncloud.com Page 7

8 Numeric Operators Operator Associativity ++, -- Nonassociative Unary +, - * Right to left ** (exponentiation) Right to left *, /, % Left to right Binary +, - Left to right numeric operations are performed in double-precision floating point. Operator Operation string concatenation x string repetition = concatenation and assignment Concatenation is performed using the operator: Example $first = "Freddy" $first " Freeloader" Result "Freddy Freeloader" x is the repetition operator. Example Result "More! " x 3 "More! More! More! " Eduoncloud.com Page 8

9 With example explain the string functions in perl String Functions Name chomp length Lc Uc Hex Join Parameter(s) A string A string A string A string A string A character and the strings concatenated together with a list of strings Actions Removes trailing newlines and returns # of removed characters Returns the # of characters in its parameter string Returns the parameter with all uppercase convert to lowercase Returns the parameter with all lowercase convert to uppercase Returns the decimal value of the hex. number in its parameter string Returns a string constructed by concatenating the strings of the second and subsequent parameters the parameter char. in between. Explain standard input output in perl with example Keyboard Input All input and output in Perl is treated as file I/O. Files have external names, but are know within the program by their internal names (known as "filehandles"). Three predefined filehandles: STDIN, STDOUT and STDERR. Eduoncloud.com Page 9

10 We get line input by writing: $in_data = <STDIN> ; #reads including newline chomp($in_data = <STDIN>); #does not read newline Screen Output The standard way of producing output is the print operator/function (which requires parentheses). takes one or more string literals separated by commas. print "This is pretty easy\n", By.. ; C's printf function and its formatting specifiers are also available Example sum.pl # Input: Two numbers, a and b # Output: sum of two numbers print "Please input the value of a "; $a = <STDIN>; print "Please input the value of b "; $b = <STDIN>; $result = $a + $b ; print "The value of the expression is: $result \n"; Running Perl programs Under Windows, UNIX and Linux, a Perl program is run by typing perl and the program's file name: perl sum.pl Eduoncloud.com Page 10

11 to see if there are errors, use the c option. If you want warnings as well, use the w option. perl w sum.pl inputfile.dat uses inputfile.dat as standard input. Relational Operators Operation Numeric Operands Is equal to* == Eq Is not equal to*!= Ne Is less than* < Lt Is greater than* > Gt Is less than or equal to* <= Le Is greater than or equal to* >= Ge Compare: a > b it produces -1, a = b produces 0, a > b produces +1 String Operand s <=> Cmp * Produces +1 if true, "" is false Assignment Operators as Control Expressions Because assignment operators have values (the value being assigned to the left-hand side), they can be used as control expressions. The following loop will execute until end of file is encountered: while ($next = <STDIN>) Eduoncloud.com Page 11

12 Selection and Loop Statements Explain briefly the different selection structures in PERL. Give examples if, if-else, if-elsif-else - similar to c and c++ Simple if: if ($ > 10) $b = $a * 2; if constructs with elsif if ($snowrate < 1) print "Light snow\n"; elsif ($snowrate < 2) else print "Moderate snow\n"; print "Heavy snow\n"; There is no switch statement in Perl. unless unless has essentially the same syntax as if, except the statements in the block are executed if the condition is false. Eduoncloud.com Page 12

13 Example is the same as: unless (sum > 1000) print "We\'re not finished yet!"; if (sum <= 1000) print "We\'re not finished yet!"; Explain briefly the different Loop structures in PERL. Give examples while, until and for loop while and for are similar to those in C. There is also until, where the loop continue as long as the condition is false. $sum = 0; $count = 1; while ( $count <= 100 ) $sum += $count; $sum = 0; $count = 1; until ( $count > 100 ) $sum += $count; for ($sum = 0, $count = 1; $count <= 100; $count++) $sum += $count; Assignment: Example:1 Write program to read N number of values, and then to compute and print sum and average of N entered values. Eduoncloud.com Page 13

14 Example:2 Write program to read all numbers till End_of_File from keyboard and then to compute and print sum and average last and next last and next provides an early exit from a loop. last breaks the program out of the innermost loop (or another loop if you use labels) next takes the program to the next iteration of the innermost (or another loop if you use labels). Example: for ($i = 0; $i > 5; $i++) if ($i == 0) last; Loops and Labels in Perl Using a label allows the programmer to decide which one of several nested loops will be exited: BIGLOOP: while ( ) while ( ) while (..) if ( ) last BIGLOOP Eduoncloud.com Page 14

15 List Literals A list is an ordered sequence of scalar values. A list literal is a parenthesized list of scalar values and is the way a list value is specified in a program. ( 1, 10, 17 ) Arrays can be assigned = ( 1, 10, 17 ) Lists can store any combination of different types of scalar values: ( $val + 1, "circles", 17 ) Explain how perl arrays different from c and c++ Arrays Arrays are variables that can store lists and begin Scalars and arrays are in different namespaces, so there is no connection between $a and $a[0]. Eduoncloud.com Page 15

16 $a = 10 = (50, 60, 70) ; print scalar = $a ; # display 10 print Element = $a[1] ; # display 60 Arrays can be assigned lists or other = ('boy', 'girl', 'dog', If a list is assigned to a scalar variable, It returns the array's length. $len A list literal with all variables can be assigned values in another list literal: ($first, $second, $third) = ("George", "Bernard", "Shaw"); This is shorthand for: $first = "George"; $second = "Bernard"; $third = "Shaw"; If an array is in that list, it will be assigned any variables not assigned to list members to its left. $third) This is shorthand for: = ("George", "Bernard", "Shaw"); $first = = ( "Bernard","Shaw" ) ; $third = ""; In such case array should be kept at the last Arrays and Subscripts Eduoncloud.com Page 16

17 Arrays in Perl use integer subscripts beginning at zero. Accessing individual = (2, 4, 6, 8); $second = $list[1]; Scalars and arrays are in different namespaces, so there is no connection between $a and $a[0]. Array Lengths Array lengths are = ("Monday", "Tuesday", "Wednesday"); $list[4] = "Friday"; If you = (2, 4, 6); list[27] = 8; # Elements are 4, but length is 28. The Last subscript in a list $#list $#list + 1 #gives array length #gives array length $#list = 99 #Set array length to 100 foreach Statement The foreach statement in Perl allows the programmer to process every member of an array: Eduoncloud.com Page 17

18 foreach $value ) $value /= 2; # divides every member by 2 $value is local to above loop. foreach treats every vacant element had a value. $list[1] = 17; $list[3] = 34; output foreach $value (@list) print "Next: $value \n"; Next: Next: 17 Next: Next: 34 Built-in Array Functions Explain the built-in Array functions available in perl with examples. 1. pop - remove and return the last item of an = ("Moe", "Curly", "Larry"); $first = 2. shift - remove and return the first item of an = ("Moe", "Curly", "Larry"); $first = 3. push - takes two parameters, An array and scalar or list. - Scalar or list is added to the end of the array. Eduoncloud.com Page 18

19 "Shemp"; 4. unshift - takes two parameters, An array and scalar or list. - Scalar or list is added to the beginning of the array. "Shemp"; Explain the built-in List functions available in perl with examples. 1. split - breaks strings into parts - using a specific character as the basis for split: $stoogestring = Curly Larry Moe = split (" ", $stoogestring); New list : ("Curly", "Larry", "Moe") 2. sort - takes an array parameter. - uses a string comparison to sort the elements of the array alphabetically in the list that it = ("Moe", "Curly", = foreach $value (@newlist) print "$value\n" Eduoncloud.com Page 19

20 3. qw - place a sequence of unquoted strings inside quotation: qw(peaches apples pears kumquats) will produce: ("peaches", "apples", "pears", "kumquats") 4. die - takes a variable number of string parameters, concatenates them and sends the result to STDERR, and terminates the program. The implicit opeator $! Stores the number of the most recent error that has occurred: Example: die "Error division by 0 in function fun2 - $! " Write Program to read file supplied from command line, then converted to uppercase, and display them in alphabetical order. An Example: process_names.pl # A simple program to illustrate the use of arrays # Input: A file, specified on command line, where line is a # person's name # Output: converted to uppercase, and display in alphabetical order $index = 0; ($name = <>) #>>> Loop to read the names $arrnames[$index++] = uc($name); #>>> Convert to uppercase and STORE in arrnames array Eduoncloud.com Page 20

21 print "\nthe sorted list of names is:\n\n\n"; #>>> Display the sorted list of names foreach $name print ("$name \n"); Hashes An associative array is an array in which each data item is paired with a key (which uniquely identifies the data). Associative arrays in Perls are called hashes. Hashes are different from arrays because: Array use numeric subscripts; hashes use string values as keys. Arrays are ordered by subscript; hashes are not really ordered. Eduoncloud.com Page 21

22 Hash names begin with %. Initializing Hashes using a list: %kids_age= ( "John" => 38, "Genny" = 36, "Jake" => 22, "Darcie" => 21 ); assigning an array to a hash: the even subscripts are the hashes, and the odd subscripts are the = (3, 5, 6, 99); %agehash ; is equivalent to %agehash = ("3" => 5, "6" => 99); Referencing a Hash Element An individual value element of a hash can be referenced by using the hash name along with the appropriate key. Curley braces are used: $myage = $arrage"abhishek"; values are added by assigning the new element value with its key: $arrage"aishwarys" = 20; Removing Hash Elements Remove at a given key : delete $arrage"genny"; Eduoncloud.com Page 22

23 An entire hash can be set to empty by 2 methods: Assigning to an empty list: %arrage = ( ); using the undef ("undefine") operator: undef %arrage; Working With Hashes exist operator: used to determine if an element with a specific key value is in the hash: if ( exists $arrage "Freddie" ) values operator: Extract hash values only keys operator: Extract hash keys only Example foreach $child ( keys %arrage) print ( "The age of $child is $arrage $child \n" = values %arrage; print "All of the ages \n"; Create a hash table in perl containing at least five entries of pair of car models and company as keys and values respectively. Write perl program to read a car model and print its company. Print all entries in a hash table Eduoncloud.com Page 23

24 Environmental Variables %ENV is a predefined hash that stores operating systems environmental variables it store information about the system on which Perl is running. The environmental variables can be accessed by any Perl program, where the keys are the variable names. They can be accessed: foreach $key (sort keys %ENV) print "$key = $ENV$key \n"; Write a perl program to display various server information like server name, server protocol, and CGI version #!C:\perl\bin\perl.exe print "Content-type: text/html\n\n"; print "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' ' \n"; print "<html xmlns = ' > \n"; print "<head> <title> About this server </title> </head> \n"; print "<body> <h1> About this server </h1>", "\n"; print "<hr>"; print "Server name :", $ENV 'SERVER_NAME',"<br>" ; print "Running on port :", $ENV 'SERVER_PORT', "<br>" ; print "Server Software :", $ENV 'SERVER_SOFTWARE', "<br>" ; print "CGI-Revision : ", $ENV 'GATEWAY_INTERFACE', "<br>" ; print "<hr> \n"; print "</body></html> \n"; References Eduoncloud.com Page 24

25 A reference is a scalar variable that references another variable or a literal (i.e., it's an address). Similar to pointers in C/C++, but are safer to use. A reference is obtained by the backslash operator before variable name: $age = 42; $ref_age = = ("Curly", "Larry", "Moe"); $ref_names = \@names References to Literals A reference to a list literal can be created by putting the literal value in square brackets: $ref_salaries = [42500, 29800, 50000, 35250]; A reference to a hash literal is created by putting the literal value in braces: $ref_ages = 'Curly' => 41, 'Larry' => 38, 'Moe' => 43 ; Dereferencing A reference can be used to specify two values: its own (which is an address) and the value stored at that address. The latter is called dereferencing. All dereferencing in Perl is explicit. This can be done by placing a extra $ in fron of the variable's name: $$ref_names[3] = "Maxine"; This can also be done by using the -> operator: $ref_names -> [3] = "Maxine"; Eduoncloud.com Page 25

26 Describe basics of perl functions. --7 Functions A function definition includes the function header and a block of code that specifies its actions. No parameters and No return-type of the result is specified. The header contains the reserved word sub and the function s name. A function declaration tells the compiler that a function with a given name will be defined elsewhere. Function s that return values can be used in an expression. Functions that do not return anything can be standalone statements. Example: sub message print "Hello!\n"; Global Variables: Variables that appear only in a function and that are implicitly declared are global. Local Variables: You can force variables to be local by using the word my or local in front of the variable: local $count = 0; my $age = 30; my($count, $sum) = (0, 0); When local and global variables conflict in name, we use the local variable. [Type text] Page 26

27 Parameters Passing ( Two mthods) Passing by value a copy of the parameters values are given to the function. (one-way communication) If changes do not need to be shared with the main program, passing by value is preferable. Passing by reference a copy of the values addresses are given to the function. (two-way communication) Passing by value Examples All Perl parameters are passed through a special variable The actual parameters are copied If an array is a parameter, it is also copied (and should be at the end of the parameter list). Hashes are flattened into is passed by value. sub add $result = $_[0] + $_[1]; print "The result was: $result\n"; To call the subroutine and get a result: add(1,2); sub add ($numbera, $numberb) [Type text] Page 27

28 $result = $numbera + $numberb; print "The result was: $result\n"; The shift function returns (and removes) the first element of an array. sub add my $num1 = shift; my $num2 = shift; my $result = $num1 + $num2; print "The result was: $result\n"; Returning value sub myfunc if (@_) return $_[0]+$_[1]; else return 0; Passing by reference References to variables can be used as actual parameters, which provides a pass by reference mechanism. sub squeeze my $ref_list = $_[0]; my foreach $value ) if ($value > 0) push(@new, $values); [Type text] Page 28

29 function call: squeeze( ); [Type text] Page 29

30 The sort Function, Revisited Sort compares members of an array as if they were string (coercing numeric values if necessary). This can be changed by giving it an explicit block of code that specifies what comparison to use: #sort numbers in ascending = sort $a <=> #sort numbers in descending = sort $b <=> #sort strings in descending = sort $b cmp An Example tst_median.pl # program to test a function that computes the median of a given array # Parameter: A reference to an array of numbers # Return value: The median of the array, where median is the middle element # of the sorted array, if the length is odd; if the length is even, the median # is the average of the two middle elements of the sorted array. sub median my $ref_list = $_[0]; $len = $#$ref_list + 1; #>>Compute the length = sort $a <=> #>>Sort the array if( $len % 2 == 1) # length is odd return $list[$len/2]; #return middle element as median else # length is even return ( $list [ $len / 2 ] + $list [ $len / 2 1 ] ) / 2; #>>> return the average of the two middle elements of the sorted array. Eduoncloud.com Page 30

31 #>>> Begin main program: Create two test = (5, 6, 8, 0, = (11, 29, 8, 18); #>>> creates array with odd elements #>>> creates array with even elements $med = median ( \@list1 ); #>>> Call median by passing reference print "The median of the first array is $med \n"; $med = median ( \@list2 ); #>>>Call median by passing reference print "The median of the second array is $med \n"; explain the basics of pattern matching in perl, and also explain substitution and transliterate operators Pattern Matching Perl has following powerful pattern-matching features 1. Pattern-matching operator: m (won't be using explicitly). 2. pattern between slashes, match implicitly against the implicit variable $_: if ( /rabbit/ ) print "rabbit appears in $_\n"; The binding operator =~ matches a variable against the pattern: if ($str =~ /^rabbit/) print "$str begins with rabbit\n" Substitutions Sometimes we may wish to alter a string that we are saving; we can do this using the substitute operator: s/pattern/newstring/ Eduoncloud.com Page 31

32 Example $str = "It ain't going to rain no more"; $str =~ s/ain't/is not/; Substitutions With Modifiers g modifier: tells to make changes for all occurrence, not just first. $str = "Roser, Is it Rose, rose or ROSE $str =~ s/rose/rose/g; # changes only two names. i modifier: tells the substitute operator to ignore case of letters: $str = "Is it Rose, rose or ROSE $str =~ s/rose/rose/ig; # changes all three to lower case. The Transliterate Operator - tr replace a character (or a class of characters) with another character (or class of characters): $str =~ tr/;/:/ ; # replace semi-colons with colons $str =~ tr/a-z/a-z/; # translate upper to lower case $str =~ tr/\,\.//; # remove all commas and periods More About split split divide a string based on different separators defined in pattern using regular expressions. = split /[., ]\s*/, $str Eduoncloud.com Page 32

33 $str will be divided into strings separated by a blank, period or comma followed by any whitespace. word_table.pl # word_table.pl # Input: A file of text in which all words are separated by # ( whitespace, comma, a semicolon, a question mark, an # exclamation point, a period or a colon) may follow whitespace. # The input file is specified on the command line. # Output: A list of all unique words in the input file, in alphabetical order. #>>> Main loop to get and process lines of input text while = split /[\.,;:!\?]\s*/; #>>> Split the lines into words foreach $word ) #>>> Loop to count the words if (exists $freq$word) $freq$word ++; else $freq$word = 1; print "\nword \t\t Frequency \n\n"; foreach $word (sort keys %freq) #>>> Display the words and their frequencies print " $word \t\t $freq$word \n"; Eduoncloud.com Page 33

34 Remembering Matches Parts of a string can be divided up among implicit variables: "4 July 1776" =~ /(\d+) (\w+) (\d+)/; print "$2 $1, $3\n"; #will display July 4, 1776 It can be very useful to match a pattern and save the portions of the string before the match, matching the pattern and after the match. These are $`(before), $& (matching) and $'(after). An Example $str = "This is a rabbit test\n"; $str =~ /rabbit/; print "Before match: $` \n ; print "Present match: $& \n ; print After match: $' \n"; output: Before match: This is a Present match: rabbit After match: test Eduoncloud.com Page 34

35 Explain file handling in perl. Explain how files can be opened for input and output in perl. 07 Explain file handling in perl with examples File Input and Output Files are references by using filehandles, whose names do NOT begin with special characters and are usually written in uppercase for greater readability. The connection between external name and filehandle are established using the open function: open( FileHandle, "FileUseSpecifier FileName" ); File Use Specifiers Character(s) Meaning < Input (the default) Eduoncloud.com Page 35

36 > >> Output, starting at the beginning of the file Output, starting at the end of the existing data on the file +> Input from and output to the file Using a File An Example open (INDAT. "<temperatures") #Open the file for input. or die "Error unable to open temperatures $!"; #If it won't open, terminate and print the error message # Print a line of output print OUTDAT "The result is: $result \n"; #Read one line of input $next_line = <INDAT>; #using file handler Reading Multiple Lines of Input The read function: used to read multiple lines of input into a scalar variable. read ( filehandle, buffer, length [, offset] ); This will read length bytes into scalar variable buffer. If offset is used, it will begin offset bytes after the file pointer. Example $chars = read (ANIMALS, $buf, 255); Using split The lines of text in the buffer can be separated using split: Eduoncloud.com Page 36

37 @lines = split /\n/, $buf; using seek Some applications seek to re-write data that has just been read. This requires the use of the +> file use specification and then moving back to the beginning of the data just read using seek. Syntax seek (filehandle, offset, base); The base is 0 (beginning of file), 1 (current position), 2 (end of file) Example seek(updat, 240, 0); Eduoncloud.com Page 37

9.1 Origins and Uses of Perl

9.1 Origins and Uses of Perl 9.1 Origins and Uses of Perl - Began in the late 1980s as a more powerful replacement for the capabilities of awk (text file processing) and sh (UNIX system administration) - Now includes sockets for communications

More information

More Perl. CS174 Chris Pollett Oct 25, 2006.

More Perl. CS174 Chris Pollett Oct 25, 2006. More Perl CS174 Chris Pollett Oct 25, 2006. Outline Loops Arrays Hashes Functions Selection Redux Last day we learned about how if-else works in Perl. Perl does not have a switch statement Like Javascript,

More information

Pathologically Eclectic Rubbish Lister

Pathologically Eclectic Rubbish Lister Pathologically Eclectic Rubbish Lister 1 Perl Design Philosophy Author: Reuben Francis Cornel perl is an acronym for Practical Extraction and Report Language. But I guess the title is a rough translation

More information

A control expression must evaluate to a value that can be interpreted as true or false.

A control expression must evaluate to a value that can be interpreted as true or false. Control Statements Control Expressions A control expression must evaluate to a value that can be interpreted as true or false. How a control statement behaves depends on the value of its control expression.

More information

(Refer Slide Time: 01:12)

(Refer Slide Time: 01:12) Internet Technology Prof. Indranil Sengupta Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture No #22 PERL Part II We continue with our discussion on the Perl

More information

CSCI 4152/6509 Natural Language Processing. Perl Tutorial CSCI 4152/6509. CSCI 4152/6509, Perl Tutorial 1

CSCI 4152/6509 Natural Language Processing. Perl Tutorial CSCI 4152/6509. CSCI 4152/6509, Perl Tutorial 1 CSCI 4152/6509 Natural Language Processing Perl Tutorial CSCI 4152/6509 Vlado Kešelj CSCI 4152/6509, Perl Tutorial 1 created in 1987 by Larry Wall About Perl interpreted language, with just-in-time semi-compilation

More information

COMS 3101 Programming Languages: Perl. Lecture 2

COMS 3101 Programming Languages: Perl. Lecture 2 COMS 3101 Programming Languages: Perl Lecture 2 Fall 2013 Instructor: Ilia Vovsha http://www.cs.columbia.edu/~vovsha/coms3101/perl Lecture Outline Control Flow (continued) Input / Output Subroutines Concepts:

More information

Introduction to Perl. c Sanjiv K. Bhatia. Department of Mathematics & Computer Science University of Missouri St. Louis St.

Introduction to Perl. c Sanjiv K. Bhatia. Department of Mathematics & Computer Science University of Missouri St. Louis St. Introduction to Perl c Sanjiv K. Bhatia Department of Mathematics & Computer Science University of Missouri St. Louis St. Louis, MO 63121 Contents 1 Introduction 1 2 Getting started 1 3 Writing Perl scripts

More information

They grow as needed, and may be made to shrink. Officially, a Perl array is a variable whose value is a list.

They grow as needed, and may be made to shrink. Officially, a Perl array is a variable whose value is a list. Arrays Perl arrays store lists of scalar values, which may be of different types. They grow as needed, and may be made to shrink. Officially, a Perl array is a variable whose value is a list. A list literal

More information

Fundamental of Programming (C)

Fundamental of Programming (C) Borrowed from lecturer notes by Omid Jafarinezhad Fundamental of Programming (C) Lecturer: Vahid Khodabakhshi Lecture 3 Constants, Variables, Data Types, And Operations Department of Computer Engineering

More information

Scripting Languages Perl Basics. Course: Hebrew University

Scripting Languages Perl Basics. Course: Hebrew University Scripting Languages Perl Basics Course: 67557 Hebrew University אליוט יפה Jaffe Lecturer: Elliot FMTEYEWTK Far More Than Everything You've Ever Wanted to Know Perl Pathologically Eclectic Rubbish Lister

More information

8/13/ /printqp.php?heading=II BSc [ ], Semester III, Allied: COMPUTER PROGRAMMING-PERL -309C&qname=309C

8/13/ /printqp.php?heading=II BSc [ ], Semester III, Allied: COMPUTER PROGRAMMING-PERL -309C&qname=309C Dr.G.R.Damodaran College of Science (Autonomous, affiliated to the Bharathiar University, recognized by the UGC)Reaccredited at the 'A' Grade Level by the NAAC and ISO 9001:2008 Certified CRISL rated 'A'

More information

15.1 Origins and Uses of Ruby

15.1 Origins and Uses of Ruby 15.1 Origins and Uses of Ruby - Designed by Yukihiro Matsumoto; released in 1996 - Use spread rapidly in Japan - Use is now growing in part because of its use in Rails - A pure object-oriented purely interpreted

More information

What is PERL?

What is PERL? Perl For Beginners What is PERL? Practical Extraction Reporting Language General-purpose programming language Creation of Larry Wall 1987 Maintained by a community of developers Free/Open Source www.cpan.org

More information

Full file at

Full file at Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class

More information

Perl. Interview Questions and Answers

Perl. Interview Questions and Answers and Answers Prepared by Abhisek Vyas Document Version 1.0 Team, www.sybaseblog.com 1 of 13 Q. How do you separate executable statements in perl? semi-colons separate executable statements Example: my(

More information

The C++ Language. Arizona State University 1

The C++ Language. Arizona State University 1 The C++ Language CSE100 Principles of Programming with C++ (based off Chapter 2 slides by Pearson) Ryan Dougherty Arizona State University http://www.public.asu.edu/~redoughe/ Arizona State University

More information

Indian Institute of Technology Kharagpur. PERL Part II. Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. I.I.T.

Indian Institute of Technology Kharagpur. PERL Part II. Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. I.I.T. Indian Institute of Technology Kharagpur PERL Part II Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. I.I.T. Kharagpur, INDIA Lecture 22: PERL Part II On completion, the student will be able

More information

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of

More information

c) Comments do not cause any machine language object code to be generated. d) Lengthy comments can cause poor execution-time performance.

c) Comments do not cause any machine language object code to be generated. d) Lengthy comments can cause poor execution-time performance. 2.1 Introduction (No questions.) 2.2 A Simple Program: Printing a Line of Text 2.1 Which of the following must every C program have? (a) main (b) #include (c) /* (d) 2.2 Every statement in C

More information

Language Basics. /* The NUMBER GAME - User tries to guess a number between 1 and 10 */ /* Generate a random number between 1 and 10 */

Language Basics. /* The NUMBER GAME - User tries to guess a number between 1 and 10 */ /* Generate a random number between 1 and 10 */ Overview Language Basics This chapter describes the basic elements of Rexx. It discusses the simple components that make up the language. These include script structure, elements of the language, operators,

More information

Chapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines.

Chapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines. Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of

More information

1. Introduction. 2. Scalar Data

1. Introduction. 2. Scalar Data 1. Introduction What Does Perl Stand For? Why Did Larry Create Perl? Why Didn t Larry Just Use Some Other Language? Is Perl Easy or Hard? How Did Perl Get to Be So Popular? What s Happening with Perl Now?

More information

Welcome to Research Computing Services training week! November 14-17, 2011

Welcome to Research Computing Services training week! November 14-17, 2011 Welcome to Research Computing Services training week! November 14-17, 2011 Monday intro to Perl, Python and R Tuesday learn to use Titan Wednesday GPU, MPI and profiling Thursday about RCS and services

More information

Regular expressions and case insensitivity

Regular expressions and case insensitivity Regular expressions and case insensitivity As previously mentioned, you can make matching case insensitive with the i flag: /\b[uu][nn][ii][xx]\b/; /\bunix\b/i; # explicitly giving case folding # using

More information

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language 1 History C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C was originally first implemented on the DEC

More information

INTRODUCTION 1 AND REVIEW

INTRODUCTION 1 AND REVIEW INTRODUTION 1 AND REVIEW hapter SYS-ED/ OMPUTER EDUATION TEHNIQUES, IN. Programming: Advanced Objectives You will learn: Program structure. Program statements. Datatypes. Pointers. Arrays. Structures.

More information

printf( Please enter another number: ); scanf( %d, &num2);

printf( Please enter another number: ); scanf( %d, &num2); CIT 593 Intro to Computer Systems Lecture #13 (11/1/12) Now that we've looked at how an assembly language program runs on a computer, we're ready to move up a level and start working with more powerful

More information

Full file at C How to Program, 6/e Multiple Choice Test Bank

Full file at   C How to Program, 6/e Multiple Choice Test Bank 2.1 Introduction 2.2 A Simple Program: Printing a Line of Text 2.1 Lines beginning with let the computer know that the rest of the line is a comment. (a) /* (b) ** (c) REM (d)

More information

12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments.

12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments. Java How to Program, 9/e Education, Inc. All Rights Reserved. } Java application programming } Use tools from the JDK to compile and run programs. } Videos at www.deitel.com/books/jhtp9/ Help you get started

More information

CSC Web Programming. Introduction to JavaScript

CSC Web Programming. Introduction to JavaScript CSC 242 - Web Programming Introduction to JavaScript JavaScript JavaScript is a client-side scripting language the code is executed by the web browser JavaScript is an embedded language it relies on its

More information

UNIT - I. Introduction to C Programming. BY A. Vijay Bharath

UNIT - I. Introduction to C Programming. BY A. Vijay Bharath UNIT - I Introduction to C Programming Introduction to C C was originally developed in the year 1970s by Dennis Ritchie at Bell Laboratories, Inc. C is a general-purpose programming language. It has been

More information

Introduction to Perl. Perl Background. Sept 24, 2007 Class Meeting 6

Introduction to Perl. Perl Background. Sept 24, 2007 Class Meeting 6 Introduction to Perl Sept 24, 2007 Class Meeting 6 * Notes on Perl by Lenwood Heath, Virginia Tech 2004 Perl Background Practical Extraction and Report Language (Perl) Created by Larry Wall, mid-1980's

More information

Data Types and Variables in C language

Data Types and Variables in C language Data Types and Variables in C language Basic structure of C programming To write a C program, we first create functions and then put them together. A C program may contain one or more sections. They are

More information

A Crash Course in Perl5

A Crash Course in Perl5 z e e g e e s o f t w a r e A Crash Course in Perl5 Part 1: Basics Zeegee Software Inc. http://www.zeegee.com/ Terms and Conditions These slides are Copyright 2008 by Zeegee Software Inc. They have been

More information

Perl. Many of these conflict with design principles of languages for teaching.

Perl. Many of these conflict with design principles of languages for teaching. Perl Perl = Practical Extraction and Report Language Developed by Larry Wall (late 80 s) as a replacement for awk. Has grown to become a replacement for awk, sed, grep, other filters, shell scripts, C

More information

Perl and Python ESA 2007/2008. Eelco Schatborn 27 September 2007

Perl and Python ESA 2007/2008. Eelco Schatborn 27 September 2007 Perl and Python ESA 2007/2008 Eelco Schatborn eelco@os3.nl 27 September 2007 ESA: Perl Vandaag: 1. Perl introduction 2. Basic Perl: types, variables, statements,... 3. Object Oriented Perl 4. Documentation

More information

Examples of Using the ARGV Array. Loop Control Operators. Next Operator. Last Operator. Perl has three loop control operators.

Examples of Using the ARGV Array. Loop Control Operators. Next Operator. Last Operator. Perl has three loop control operators. Examples of Using the ARGV Array # mimics the Unix echo utility foreach (@ARGV) { print $_ ; print \n ; # count the number of command line arguments $i = 0; foreach (@ARGV) { $i++; print The number of

More information

Reserved Words and Identifiers

Reserved Words and Identifiers 1 Programming in C Reserved Words and Identifiers Reserved word Word that has a specific meaning in C Ex: int, return Identifier Word used to name and refer to a data element or object manipulated by the

More information

PERL Scripting - Course Contents

PERL Scripting - Course Contents PERL Scripting - Course Contents Day - 1 Introduction to PERL Comments Reading from Standard Input Writing to Standard Output Scalar Variables Numbers and Strings Use of Single Quotes and Double Quotes

More information

The PCAT Programming Language Reference Manual

The PCAT Programming Language Reference Manual The PCAT Programming Language Reference Manual Andrew Tolmach and Jingke Li Dept. of Computer Science Portland State University September 27, 1995 (revised October 15, 2002) 1 Introduction The PCAT language

More information

Beginning Perl. Mark Senn. September 11, 2007

Beginning Perl. Mark Senn. September 11, 2007 GoBack Beginning Perl Mark Senn September 11, 2007 Overview Perl is a popular programming language used to write systen software, text processing tools, World Wide Web CGI programs, etc. It was written

More information

Language Reference Manual

Language Reference Manual TAPE: A File Handling Language Language Reference Manual Tianhua Fang (tf2377) Alexander Sato (as4628) Priscilla Wang (pyw2102) Edwin Chan (cc3919) Programming Languages and Translators COMSW 4115 Fall

More information

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved. Assoc. Prof. Dr. Marenglen Biba (C) 2010 Pearson Education, Inc. All rights reserved. Java application A computer program that executes when you use the java command to launch the Java Virtual Machine

More information

Programming for Engineers Introduction to C

Programming for Engineers Introduction to C Programming for Engineers Introduction to C ICEN 200 Spring 2018 Prof. Dola Saha 1 Simple Program 2 Comments // Fig. 2.1: fig02_01.c // A first program in C begin with //, indicating that these two lines

More information

Chapter 2: Introduction to C++

Chapter 2: Introduction to C++ Chapter 2: Introduction to C++ Copyright 2010 Pearson Education, Inc. Copyright Publishing as 2010 Pearson Pearson Addison-Wesley Education, Inc. Publishing as Pearson Addison-Wesley 2.1 Parts of a C++

More information

3 The Building Blocks: Data Types, Literals, and Variables

3 The Building Blocks: Data Types, Literals, and Variables chapter 3 The Building Blocks: Data Types, Literals, and Variables 3.1 Data Types A program can do many things, including calculations, sorting names, preparing phone lists, displaying images, validating

More information

IT 374 C# and Applications/ IT695 C# Data Structures

IT 374 C# and Applications/ IT695 C# Data Structures IT 374 C# and Applications/ IT695 C# Data Structures Module 2.1: Introduction to C# App Programming Xianrong (Shawn) Zheng Spring 2017 1 Outline Introduction Creating a Simple App String Interpolation

More information

Chapter 2: Special Characters. Parts of a C++ Program. Introduction to C++ Displays output on the computer screen

Chapter 2: Special Characters. Parts of a C++ Program. Introduction to C++ Displays output on the computer screen Chapter 2: Introduction to C++ 2.1 Parts of a C++ Program Copyright 2009 Pearson Education, Inc. Copyright 2009 Publishing Pearson as Pearson Education, Addison-Wesley Inc. Publishing as Pearson Addison-Wesley

More information

Outline. CS3157: Advanced Programming. Feedback from last class. Last plug

Outline. CS3157: Advanced Programming. Feedback from last class. Last plug Outline CS3157: Advanced Programming Lecture #2 Jan 23 Shlomo Hershkop shlomo@cs.columbia.edu Feedback Introduction to Perl review and continued Intro to Regular expressions Reading Programming Perl pg

More information

Visual C# Instructor s Manual Table of Contents

Visual C# Instructor s Manual Table of Contents Visual C# 2005 2-1 Chapter 2 Using Data At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class Discussion Topics Additional Projects Additional Resources Key Terms

More information

Learning Language. Reference Manual. George Liao (gkl2104) Joseanibal Colon Ramos (jc2373) Stephen Robinson (sar2120) Huabiao Xu(hx2104)

Learning Language. Reference Manual. George Liao (gkl2104) Joseanibal Colon Ramos (jc2373) Stephen Robinson (sar2120) Huabiao Xu(hx2104) Learning Language Reference Manual 1 George Liao (gkl2104) Joseanibal Colon Ramos (jc2373) Stephen Robinson (sar2120) Huabiao Xu(hx2104) A. Introduction Learning Language is a programming language designed

More information

EDIABAS BEST/2 LANGUAGE DESCRIPTION. VERSION 6b. Electronic Diagnostic Basic System EDIABAS - BEST/2 LANGUAGE DESCRIPTION

EDIABAS BEST/2 LANGUAGE DESCRIPTION. VERSION 6b. Electronic Diagnostic Basic System EDIABAS - BEST/2 LANGUAGE DESCRIPTION EDIABAS Electronic Diagnostic Basic System BEST/2 LANGUAGE DESCRIPTION VERSION 6b Copyright BMW AG, created by Softing AG BEST2SPC.DOC CONTENTS CONTENTS...2 1. INTRODUCTION TO BEST/2...5 2. TEXT CONVENTIONS...6

More information

The SPL Programming Language Reference Manual

The SPL Programming Language Reference Manual The SPL Programming Language Reference Manual Leonidas Fegaras University of Texas at Arlington Arlington, TX 76019 fegaras@cse.uta.edu February 27, 2018 1 Introduction The SPL language is a Small Programming

More information

Lexical Considerations

Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Fall 2005 Handout 6 Decaf Language Wednesday, September 7 The project for the course is to write a

More information

JME Language Reference Manual

JME Language Reference Manual JME Language Reference Manual 1 Introduction JME (pronounced jay+me) is a lightweight language that allows programmers to easily perform statistic computations on tabular data as part of data analysis.

More information

ARG! Language Reference Manual

ARG! Language Reference Manual ARG! Language Reference Manual Ryan Eagan, Mike Goldin, River Keefer, Shivangi Saxena 1. Introduction ARG is a language to be used to make programming a less frustrating experience. It is similar to C

More information

Perl. Perl. Perl. Which Perl

Perl. Perl. Perl. Which Perl Perl Perl Perl = Practical Extraction and Report Language Developed by Larry Wall (late 80 s) as a replacement for awk. Has grown to become a replacement for awk, sed, grep, other filters, shell scripts,

More information

2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program

2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program Chapter 2: Introduction to C++ 2.1 Parts of a C++ Program Copyright 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Parts of a C++ Program Parts of a C++ Program // sample C++ program

More information

COMS 3101 Programming Languages: Perl. Lecture 1

COMS 3101 Programming Languages: Perl. Lecture 1 COMS 3101 Programming Languages: Perl Lecture 1 Fall 2013 Instructor: Ilia Vovsha http://www.cs.columbia.edu/~vovsha/coms3101/perl What is Perl? Perl is a high level language initially developed as a scripting

More information

UNIT- 3 Introduction to C++

UNIT- 3 Introduction to C++ UNIT- 3 Introduction to C++ C++ Character Sets: Letters A-Z, a-z Digits 0-9 Special Symbols Space + - * / ^ \ ( ) [ ] =!= . $, ; : %! &? _ # = @ White Spaces Blank spaces, horizontal tab, carriage

More information

Copyright 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Chapter 11 Introduction to PHP

Copyright 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Chapter 11 Introduction to PHP Chapter 11 Introduction to PHP 11.1 Origin and Uses of PHP Developed by Rasmus Lerdorf in 1994 PHP is a server-side scripting language, embedded in XHTML pages PHP has good support for form processing

More information

RTL Reference 1. JVM. 2. Lexical Conventions

RTL Reference 1. JVM. 2. Lexical Conventions RTL Reference 1. JVM Record Transformation Language (RTL) runs on the JVM. Runtime support for operations on data types are all implemented in Java. This constrains the data types to be compatible to Java's

More information

Java Notes. 10th ICSE. Saravanan Ganesh

Java Notes. 10th ICSE. Saravanan Ganesh Java Notes 10th ICSE Saravanan Ganesh 13 Java Character Set 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

More information

Chapter 2: Basic Elements of C++

Chapter 2: Basic Elements of C++ Chapter 2: Basic Elements of C++ Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates

More information

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program Objectives Chapter 2: Basic Elements of C++ In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates

More information

Bamuengine.com. Chapter 14. Perl The Mater Manipulator

Bamuengine.com. Chapter 14. Perl The Mater Manipulator Chapter 14. Perl The Mater Manipulator Introduciton The following sections tell you what Perl is, the variables and operators in perl, the string handling functions. The chapter also discusses file handling

More information

Regular expressions and case insensitivity

Regular expressions and case insensitivity Regular expressions and case insensitivity As previously mentioned, you can make matching case insensitive with the i flag: /\b[uu][nn][ii][xx]\b/; # explicitly giving case folding /\bunix\b/i; # using

More information

JavaScript I Language Basics

JavaScript I Language Basics JavaScript I Language Basics Chesapeake Node.js User Group (CNUG) https://www.meetup.com/chesapeake-region-nodejs-developers-group START BUILDING: CALLFORCODE.ORG Agenda Introduction to JavaScript Language

More information

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction Chapter 2: Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 1 Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers

More information

Crayon (.cry) Language Reference Manual. Naman Agrawal (na2603) Vaidehi Dalmia (vd2302) Ganesh Ravichandran (gr2483) David Smart (ds3361)

Crayon (.cry) Language Reference Manual. Naman Agrawal (na2603) Vaidehi Dalmia (vd2302) Ganesh Ravichandran (gr2483) David Smart (ds3361) Crayon (.cry) Language Reference Manual Naman Agrawal (na2603) Vaidehi Dalmia (vd2302) Ganesh Ravichandran (gr2483) David Smart (ds3361) 1 Lexical Elements 1.1 Identifiers Identifiers are strings used

More information

T-( )-MALV, Natural Language Processing The programming language Perl

T-( )-MALV, Natural Language Processing The programming language Perl T-(538 725)-MALV, Natural Language Processing The programming language Perl Hrafn Loftsson 1 Hannes Högni Vilhjálmsson 1 1 School of Computer Science, Reykjavik University September 2010 Outline 1 Perl

More information

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York CSc 10200! Introduction to Computing Lecture 2-3 Edgardo Molina Fall 2013 City College of New York 1 C++ for Engineers and Scientists Third Edition Chapter 2 Problem Solving Using C++ 2 Objectives In this

More information

Fundamentals of Programming. Lecture 3: Introduction to C Programming

Fundamentals of Programming. Lecture 3: Introduction to C Programming Fundamentals of Programming Lecture 3: Introduction to C Programming Instructor: Fatemeh Zamani f_zamani@ce.sharif.edu Sharif University of Technology Computer Engineering Department Outline A Simple C

More information

ADARSH VIDYA KENDRA NAGERCOIL COMPUTER SCIENCE. Grade: IX C++ PROGRAMMING. Department of Computer Science 1

ADARSH VIDYA KENDRA NAGERCOIL COMPUTER SCIENCE. Grade: IX C++ PROGRAMMING. Department of Computer Science 1 NAGERCOIL COMPUTER SCIENCE Grade: IX C++ PROGRAMMING 1 C++ 1. Object Oriented Programming OOP is Object Oriented Programming. It was developed to overcome the flaws of the procedural approach to programming.

More information

PHP Personal Home Page PHP: Hypertext Preprocessor (Lecture 35-37)

PHP Personal Home Page PHP: Hypertext Preprocessor (Lecture 35-37) PHP Personal Home Page PHP: Hypertext Preprocessor (Lecture 35-37) A Server-side Scripting Programming Language An Introduction What is PHP? PHP stands for PHP: Hypertext Preprocessor. It is a server-side

More information

Language Reference Manual

Language Reference Manual ALACS Language Reference Manual Manager: Gabriel Lopez (gal2129) Language Guru: Gabriel Kramer-Garcia (glk2110) System Architect: Candace Johnson (crj2121) Tester: Terence Jacobs (tj2316) Table of Contents

More information

C - Basic Introduction

C - Basic Introduction C - Basic Introduction C is a general-purpose high level language that was originally developed by Dennis Ritchie for the UNIX operating system. It was first implemented on the Digital Equipment Corporation

More information

Fundamentals of Programming Session 4

Fundamentals of Programming Session 4 Fundamentals of Programming Session 4 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Fall 2011 These slides are created using Deitel s slides, ( 1992-2010 by Pearson Education, Inc).

More information

Work relative to other classes

Work relative to other classes Work relative to other classes 1 Hours/week on projects 2 C BOOTCAMP DAY 1 CS3600, Northeastern University Slides adapted from Anandha Gopalan s CS132 course at Univ. of Pittsburgh Overview C: A language

More information

Object oriented programming. Instructor: Masoud Asghari Web page: Ch: 3

Object oriented programming. Instructor: Masoud Asghari Web page:   Ch: 3 Object oriented programming Instructor: Masoud Asghari Web page: http://www.masses.ir/lectures/oops2017sut Ch: 3 1 In this slide We follow: https://docs.oracle.com/javase/tutorial/index.html Trail: Learning

More information

A Fast Review of C Essentials Part I

A Fast Review of C Essentials Part I A Fast Review of C Essentials Part I Structural Programming by Z. Cihan TAYSI Outline Program development C Essentials Functions Variables & constants Names Formatting Comments Preprocessor Data types

More information

CMSC 331 Final Exam Fall 2013

CMSC 331 Final Exam Fall 2013 CMSC 331 Final Exam Fall 2013 Name: UMBC username: You have two hours to complete this closed book exam. Use the backs of these pages if you need more room for your answers. Describe any assumptions you

More information

The Power of Perl. Perl. Perl. Change all gopher to World Wide Web in a single command

The Power of Perl. Perl. Perl. Change all gopher to World Wide Web in a single command The Power of Perl Perl Change all gopher to World Wide Web in a single command perl -e s/gopher/world Wide Web/gi -p -i.bak *.html Perl can be used as a command Or like an interpreter UVic SEng 265 Daniel

More information

BITG 1233: Introduction to C++

BITG 1233: Introduction to C++ BITG 1233: Introduction to C++ 1 Learning Outcomes At the end of this lecture, you should be able to: Identify basic structure of C++ program (pg 3) Describe the concepts of : Character set. (pg 11) Token

More information

DaMPL. Language Reference Manual. Henrique Grando

DaMPL. Language Reference Manual. Henrique Grando DaMPL Language Reference Manual Bernardo Abreu Felipe Rocha Henrique Grando Hugo Sousa bd2440 flt2107 hp2409 ha2398 Contents 1. Getting Started... 4 2. Syntax Notations... 4 3. Lexical Conventions... 4

More information

Programming Perls* Objective: To introduce students to the perl language.

Programming Perls* Objective: To introduce students to the perl language. Programming Perls* Objective: To introduce students to the perl language. Perl is a language for getting your job done. Making Easy Things Easy & Hard Things Possible Perl is a language for easily manipulating

More information

1 Lexical Considerations

1 Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2013 Handout Decaf Language Thursday, Feb 7 The project for the course is to write a compiler

More information

Overview: Programming Concepts. Programming Concepts. Names, Values, And Variables

Overview: Programming Concepts. Programming Concepts. Names, Values, And Variables Chapter 18: Get With the Program: Fundamental Concepts Expressed in JavaScript Fluency with Information Technology Third Edition by Lawrence Snyder Overview: Programming Concepts Programming: Act of formulating

More information

Overview: Programming Concepts. Programming Concepts. Chapter 18: Get With the Program: Fundamental Concepts Expressed in JavaScript

Overview: Programming Concepts. Programming Concepts. Chapter 18: Get With the Program: Fundamental Concepts Expressed in JavaScript Chapter 18: Get With the Program: Fundamental Concepts Expressed in JavaScript Fluency with Information Technology Third Edition by Lawrence Snyder Overview: Programming Concepts Programming: Act of formulating

More information

Typescript on LLVM Language Reference Manual

Typescript on LLVM Language Reference Manual Typescript on LLVM Language Reference Manual Ratheet Pandya UNI: rp2707 COMS 4115 H01 (CVN) 1. Introduction 2. Lexical Conventions 2.1 Tokens 2.2 Comments 2.3 Identifiers 2.4 Reserved Keywords 2.5 String

More information

LECTURE 02 INTRODUCTION TO C++

LECTURE 02 INTRODUCTION TO C++ PowerPoint Slides adapted from *Starting Out with C++: From Control Structures through Objects, 7/E* by *Tony Gaddis* Copyright 2012 Pearson Education Inc. COMPUTER PROGRAMMING LECTURE 02 INTRODUCTION

More information

Chapter 17. Fundamental Concepts Expressed in JavaScript

Chapter 17. Fundamental Concepts Expressed in JavaScript Chapter 17 Fundamental Concepts Expressed in JavaScript Learning Objectives Tell the difference between name, value, and variable List three basic data types and the rules for specifying them in a program

More information

Basics of Java Programming

Basics of Java Programming Basics of Java Programming Lecture 2 COP 3252 Summer 2017 May 16, 2017 Components of a Java Program statements - A statement is some action or sequence of actions, given as a command in code. A statement

More information

C How to Program, 6/e by Pearson Education, Inc. All Rights Reserved.

C How to Program, 6/e by Pearson Education, Inc. All Rights Reserved. C How to Program, 6/e 1992-2010 by Pearson Education, Inc. An important part of the solution to any problem is the presentation of the results. In this chapter, we discuss in depth the formatting features

More information

Should you know scanf and printf?

Should you know scanf and printf? C-LANGUAGE INPUT & OUTPUT C-Language Output with printf Input with scanf and gets_s and Defensive Programming Copyright 2016 Dan McElroy Should you know scanf and printf? scanf is only useful in the C-language,

More information

egrapher Language Reference Manual

egrapher Language Reference Manual egrapher Language Reference Manual Long Long: ll3078@columbia.edu Xinli Jia: xj2191@columbia.edu Jiefu Ying: jy2799@columbia.edu Linnan Wang: lw2645@columbia.edu Darren Chen: dsc2155@columbia.edu 1. Introduction

More information

Expr Language Reference

Expr Language Reference Expr Language Reference Expr language defines expressions, which are evaluated in the context of an item in some structure. This article describes the syntax of the language and the rules that govern the

More information

COMP 2718: Shell Scripts: Part 1. By: Dr. Andrew Vardy

COMP 2718: Shell Scripts: Part 1. By: Dr. Andrew Vardy COMP 2718: Shell Scripts: Part 1 By: Dr. Andrew Vardy Outline Shell Scripts: Part 1 Hello World Shebang! Example Project Introducing Variables Variable Names Variable Facts Arguments Exit Status Branching:

More information

Indian Institute of Technology Kharagpur. PERL Part III. Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. I.I.T.

Indian Institute of Technology Kharagpur. PERL Part III. Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. I.I.T. Indian Institute of Technology Kharagpur PERL Part III Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. I.I.T. Kharagpur, INDIA Lecture 23: PERL Part III On completion, the student will be able

More information