PERL. Pattern Extraction and Reporting Language. Example: $x = 10 $value = $x + 1 $word = "hello"

Size: px
Start display at page:

Download "PERL. Pattern Extraction and Reporting Language. Example: $x = 10 $value = $x + 1 $word = "hello""

Transcription

1 PERL Pattern Extraction and Reporting Language Example: Web page serving through CGI: Perl is used extensively in serving up content when run in concert with a web-server. Talking to web sites and reporting on bits of info: Perl can go and visit a website for you, without you ever using a browser. Database Management: Perl comes with the capability to interact with online "backend" databases -- the massive storehouses of information running behind the scenes on large websites. System Administration: Scripts for automating almost anything. Running Perl Scripts: Create a file hello.pl: print "hello world\n"; Run it by typing: perl hello.pl Variables and Types: Scalars. A scalar is a single piece of information. Scalars can hold numbers or text. Scalars are given names (just like the unknown x is in algebra) but these names always must start with a $ sign (for scalar). $x = 10 $value = $x + 1 $word = "hello" Arrays. Arrays hold multiple pieces of information that can all be referrred to at once. Arrays can hold numbers or text and their names always start with sign (for array). They can have as many values within them as you'd like. Here are some examples of arrays:

2 @array = (1, 2 = ( "first", "second", "third" = ( $x, $y, 3, 5) Subscripts start at 0, not 1. Notice that since you are extracting a single value out of it, you are referring to a scalar, and therefore you change the prefix to a $. Given the examples above: $array[0] has the value 1 $array[1] has the value 2 $words[0] has the value "first" "list context", i.e., put into parentheses. So ($x, $y, $z ) = ( 1, 2, 3); would assign the values 1, 2, 3 to $x, $y, $z respectively. This "list context" idea comes up frequently in Perl. Hashes. Hashes a really great part of perl, and they are extremely useful in practice. Hashes are just special arrays. They are special because instead of having numerical indexes into the elements, like [0], they have words as the indexes. The curly braces suggest that they are fancy arrays. To make a hash element, you just define it, using a key and value pair: $servings{pizza = 30; $servings{coke = 40; $servings{spumoni = 12; The keys above are "pizza", "coke", and "spumoni", and the values are 30, 40, and 12. You could use strings for values too: $occupation{jeff = "manager"; $occupation{martha = "interior designer";

3 Here the keys are Jeff and Martha, and the values are manager and interior designer. If you want to refer to the hash itself, you use a % sign, so these hashes would be %servings and %occupation. The default variable. Perl provides a default variable designated with an underscore symbol: $_. Just as this name suggests, it is a scalar variable with the name "underscore". This variable is used whenever a variable is required, but where you're too lazy to bother specifying one. As a specific example, suppose this default variable, $_, has the value of "hello world". Since the print statement normally requires a variable to print, if you leave it out the default variable will be used. So if you write: print; then you'll get hello world Flow Control If-Else The if-else combination is one of the most important control statements in any programming language. The idea is that if a condition is true, do one thing, and if it's not true, do something else. An example will show how it works: $myname = "Mike"; if ( $myname eq "Mike" ) { print "Hi Mike\n"; else { print "You're not Mike!\n";

4 While $x = 0; while ( $x < 4 ) { print "X is less than 4\n"; $x = $x + 1; print "X is finally equal to 4"; For for ( ) { print "I'm doing this 3 times!\n"; Another use for the for loop is working through an = ( "red", "green", "blue"); for $color ) { print $color; print "\n"; Hashes are often used in conjunction with the for loop and the special function "keys" which returns all the keys from a hash as an array: $servings{pizza = 30; $servings{coke = 40; $servings{spumoni = 12; for $key ( keys ( %servings ) ) { print "We served $servings{$key helpings of $key\n";

5 Some Simple Perl Scripts To get an idea of how Perl works, we'll finish off the first lesson with some simple Perl scripts. We'll build on the items you've learned earlier: scalars and arrays, the ifelse, while and for constructs, and the print statement. Statements Statements are complete thoughts in perl, just like sentences. In English, sentences end with a period. In Perl, statements must end with a semi-colon. This is for good reason in perl the period is used for something else. Comments In perl, comments are set off with the "#" character. Anything following the # to the end of the line is a comment. For example: #This illustrates a comment. There is another form of comment which is very useful when you want to chop out large sections of code. This technique is used for Perl's embedded documentation, i.e. to create the POD files: =comment until cut $variable = 1; print "The variable has the value of $variable\n"; =cut The Newline Character print " Skip to the new line after this sentence.\n";

6 Short Forms In perl, some operations are so common they have a shortened form that saves time. These may be strange to the novice, so I'll be careful here. Programming Errors If you have a mistake in your perl script that makes your meaning unclear, you'll get a message from the perl compiler when you try to run it. To check for these errors before running, you can run perl with the -c flag. And turn on the warnings flag, -w, while you're at it. This picks up hard to find errors too. As an example you'd type in: perl -wc hello.pl to check on the health of the perl script, hello.pl. If there are any syntax errors, you'll hear about them alright! Running the example scripts You can copy any of the following script examples into a file in Notepad and save it as, say, perltest.pl. Then check it for errors by typing perl -wc perltest.pl If it comes back saying "syntax ok", then go ahead and run it by typing perl perltest.pl If it doesn't say "syntax ok", then go and fix the reported error, and try again. Script 1: Adding the numbers 1 to 100, Version 1 $top_number = 100; $x = 1; $total = 0; while ( $x <= $top_number ) { $total = $total + $x; # short form: $total += $x;

7 $x += 1; # do you follow this short form? print "The total from 1 to $top_number is $total\n"; Script 2: Adding the numbers 1 to 100. Version 2 This script uses a form of the for loop to go through the integers 1 through 100: $total = 0; #the for loop gives $x the value of all the #numbers from 1 to 100; for $x ( ) { $total += $x; # again, the short form print "The total from 1 to 100 is $total\n"; Script 3: Printing a menu This script uses an array to store flavors. It also uses a terrific form of the for loop to go through = ( "vanilla", "chocolate", "strawberry" ); for $flavor ) { print "We have $flavor milkshakes\n"; print "They are 2.95 each\n"; print "Please your order for home delivery\n";

8 Script 4: Going one way or the other: This allows you to program in a word to make a decision. The "ne" in the if statement stands for "not equal" and is used to compare text. The "die" statement shows you a way to get out of a program when you're in trouble. #You can program answer to be heads or tails $answer = "heads"; if ( $answer ne "heads" and $answer ne "tails" ) { die "Answer has a bad value: $answer!"; print "Answer is programmed to be $answer.\n"; if ( $answer eq "heads" ) { print "HEADS! you WON!\n"; else { print "TAILS?! you lost. Try your coding again!\n"; Script 5: Going one way or the other, interactively: This allows you to type in a word to make a decision. A shameless sneak peek at the next lesson on input and output. <STDIN> allows us to read a word from the keyboard, and "chomp" is a function to remove the newline that's attached to our answer after hitting the carriage return. print "Please type in either heads or tails: "; #The <STDIN> is the way to read keyboard input $answer = <STDIN>; chomp $answer;

9 while ( $answer ne "heads" and $answer ne "tails" ) { print "I asked you to type heads or tails. Please do so: "; $answer = <STDIN>; chomp $answer; print "Thanks. You chose $answer.\n"; print "Hit enter key to continue: "; #This line is here to pause the script until you hit the carriage return #but the input is never used for anything. $_ = <STDIN>; if ( $answer eq "heads" ) { print "HEADS! you WON!\n"; else { print "TAILS?! you lost. Try again!\n"; Introduction to CGI The rest of this introductory Perl course will describe how you can make Perl interact with a browser through the Common Gateway Interface, or CGI. CGI is a standard interface that sits between the web browser and the web server. When the browser makes a request of the server, all of the request details flow into the server through the input interface of the CGI. When the server responds with its output, the information flows back out through the output interface of the CGI. When Perl responds to a browser request it sends output to STDOUT which is sent through CGI back to the browser. Because you know how to print data to STDOUT,

10 you can already work with CGI at its most basic level: sending data to it. It is no more complicated than printing to STDOUT. Sending your first page to the browser Let's look at a simple page: print "Content-Type: text/html\n\n"; print "<HTML>\n"; print "<HEAD>\n"; print "<TITLE>Hello World</TITLE>\n"; print "</HEAD>\n"; print "<BODY>\n"; print "<H4>Hello World</H4>\n"; print "<P>\n"; print "Your IP Address is $ENV{REMOTE_ADDR.\n"; print "<P>"; print "<H5>Have a nice day</h5>\n"; print "</BODY>\n"; print "</HTML>\n"; First of all, it should be clear that this is Perl program does nothing but print HTML text to STDOUT. That's pretty much all there is to sending data out through CGI! The output does have to follow certain rules through. You can't just print anything you want and expect it to be interpreted by the browser correctly. The first thing that your program must do is to tell the browser what kind of information follows. Since we are sending HTML output, we must inform the browser that the content is text in HTML format. That's what the first line is for. (It's a standard MIME header.) If you were just outputting plain text to your browser, then you could put "text/plain" instead of "text/html".

11 It is very important to send two newlines after the header, i.e., a single blank line, otherwise the browser will complain of bad header information. After the content type header, there is just a complete section of HTML. The only odd bit in the script is the line: print "Your IP Address is $ENV{REMOTE_ADDR.\n"; As you have seen, this prints your numeric IP address in the browser window. But what is $ENV{REMOTE_ADDR? The answer will become clear later. For now just accept that it is part of the data delivered to the input of CGI. How you get at data will come later. Let's look at a couple of alternatives to repeated print statements because TIMTOWTDI! Let's quote the whole thing within a variable and just print once: $html = "Content-Type: text/html <HTML> <HEAD> <TITLE>Hello World</TITLE> </HEAD> <BODY> <H4>Hello World</H4> <P> Your IP Address is $ENV{REMOTE_ADDR <P> <H5>Have a nice day</h5> </BODY> </HTML>"; print $html; This is easier because of two things. We don't have to keep track of quotes around many strings, and we can let the new lines within the block itself specify the \n

12 characters. But now that we're quoting, suppose we wanted to put the word nice into quotation marks? If we wrote: <H5>Have a "nice" day</h5> in the original script, we'd get a syntax error, because the two quote marks we put in would match with the opening and closing quotes already there. The solution is to backquote the new ones, like this: <H5>Have a \"nice\" day</h5> This takes away the syntax error since the quotes are interpreted as part of the string itself. Sometimes though, this backquoting gets to be too much of a pain when there a lots of quotes such as in the next example. In that case, you can use a different quoting delimiter, and use the explicit quoting operator, qq{. $html = qq{content-type: text/html <HTML> <HEAD> <TITLE>Hello World</TITLE> </HEAD> <BODY> <H4>Hello World</H4> <P> Your IP Address is $ENV{REMOTE_ADDR <P> <H5>Have a "nice" day</h5> <p>name:<input type="text" size="20" name="txt_name" value="name"> </BODY> </HTML>; print $html;

13 Alternatively, you can also use the "here document" form of printing. "Here documents" originate in Unix shell programming. With qq's ability to quote over newlines, it s not clear what advantage they offer. In any case, here's an example: print <<EOF; Content-Type: text/html <HTML> <HEAD> <TITLE>Hello World</TITLE> </HEAD> <BODY> <H4>Hello World</H4> <P> Your IP Address is $ENV{REMOTE_ADDR <P> <H5>Have a "nice" day</h5> <p>name:<input type="text" size="20" name="txt_name" value="name"> </BODY> </HTML> EOF The "here document" always follows the form: print <<TAG;... TAG It is an alternative to the quotation operator. These previous examples are very simple since they just print out an explicit string of html. But Perl begins to be useful in the role of serving content when you make up the output with your program, like this example of code to print a table of squares. In this example, we are defining two control parameters, $title and $rows, at the top

14 in a couple of global variables, and we use two functions to provide the head and body content of the HTML. (Caution: global variables are not recommended once you are no longer a beginner. There's too much potential for inadvertently changing their values, so don't do it all the time. You've been warned.) $title = "Table of Squares"; $rows=10; print "Content-Type: text/html\n\n"; print header(); print body(); sub header() { return qq{<html>\n<head>\n<title>$title</title></head>; sub body() { $body = qq{ <BODY> <div align="center"> <H4>$title</H4> <P> <table border="1"> ; for $i ( 1.. $rows ) { $body.= qq{<tr><td>row $i</td>; $body.= qq{<td width="50" align="center">; $body.= $i*$i; $body.= qq{</td></tr>\n; $body.= qq{

15 </table> </div> </BODY> </HTML>; return $body; Serving Edited Files Now that you know how to fetch and serve an existing HTML file, you can use it as the basis for editing. Try saving this web page as "editing.html" in your cgi-bin directory and running this perl script: print "Content-Type: text/html\n\n"; open HTML, "editing.html" or die $!; while( <HTML> ) { s{<title>.*?</title>{<title>sub'n'serve Demo</title>; s{<h2.*?</h2>{<h2>substituted Header!</H2>i; print; close HTML; Introduction to GET and POST use CGI; $cgi = new CGI; print qq{content-type: text/html <html><head></head><body>; #print every key in the environment foreach $key (sort (keys %ENV)) { print $key, ' = ', $ENV{$key, "<br>\n";

16 #print a couple of simple forms: a POST form and a GET form print qq{<form method="post" action= cgi-bin/getpost.pl > <input type="submit" value="post Request"> <input name="postfield"></form>; print qq{<form method="get" action= cgi-bin/getpost.pl > <input type="submit" value="get Request "> <input name="getfield" ></form>; print qq{</body></html>; CGI.pm does everything you need to read user input, create forms, handle cookies, handle redirection, and more. It is a very useful module indeed and it is a standard module supplied with your Perl installation. This next script prints out any input parameters supplied to the script through either GET or POST. Try saving this script as getpost.pl and running it in your browser window. use CGI; $cgi = new CGI; for $key ( $cgi->param() ) { $input{$key = $cgi->param($key); print qq{content-type: text/html <html><head></head><body> ; for $key ( keys %input ) { print $key, ' = ', $input{$key, "<br>\n"; print qq{</body></html>;

(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

MITOCW watch?v=0jljzrnhwoi

MITOCW watch?v=0jljzrnhwoi MITOCW watch?v=0jljzrnhwoi The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high quality educational resources for free. To

More information

BEGINNER PHP Table of Contents

BEGINNER PHP Table of Contents Table of Contents 4 5 6 7 8 9 0 Introduction Getting Setup Your first PHP webpage Working with text Talking to the user Comparison & If statements If & Else Cleaning up the game Remembering values Finishing

More information

Web forms and CGI scripts

Web forms and CGI scripts Web forms and CGI scripts Dr. Andrew C.R. Martin andrew.martin@ucl.ac.uk http://www.bioinf.org.uk/ Aims and objectives Understand how the web works Be able to create forms on HTML pages Understand how

More information

CHAPTER 2. Troubleshooting CGI Scripts

CHAPTER 2. Troubleshooting CGI Scripts CHAPTER 2 Troubleshooting CGI Scripts OVERVIEW Web servers and their CGI environment can be set up in a variety of ways. Chapter 1 covered the basics of the installation and configuration of scripts. However,

More information

CGI Programming. What is "CGI"?

CGI Programming. What is CGI? CGI Programming What is "CGI"? Common Gateway Interface A means of running an executable program via the Web. CGI is not a Perl-specific concept. Almost any language can produce CGI programs even C++ (gasp!!)

More information

WICKED COOL PERL SCRIPTS

WICKED COOL PERL SCRIPTS WICKED COOL PERL SCRIPTS Useful Perl Scripts That Solve Difficult Problems by Steve Oualline San Francisco 3 CGI DEBUGGING #10 Hello World Perl and the Web were made for each other. The Perl language is

More information

Lesson 3 Transcript: Part 2 of 2 Tools & Scripting

Lesson 3 Transcript: Part 2 of 2 Tools & Scripting Lesson 3 Transcript: Part 2 of 2 Tools & Scripting Slide 1: Cover Welcome to lesson 3 of the DB2 on Campus Lecture Series. Today we are going to talk about tools and scripting. And this is part 2 of 2

More information

Writing Perl Programs using Control Structures Worked Examples

Writing Perl Programs using Control Structures Worked Examples Writing Perl Programs using Control Structures Worked Examples Louise Dennis October 27, 2004 These notes describe my attempts to do some Perl programming exercises using control structures and HTML Forms.

More information

Post Experiment Interview Questions

Post Experiment Interview Questions Post Experiment Interview Questions Questions about the Maximum Problem 1. What is this problem statement asking? 2. What is meant by positive integers? 3. What does it mean by the user entering valid

More information

Notes By: Shailesh Bdr. Pandey, TA, Computer Engineering Department, Nepal Engineering College

Notes By: Shailesh Bdr. Pandey, TA, Computer Engineering Department, Nepal Engineering College Preparing to Program You should take certain steps when you're solving a problem. First, you must define the problem. If you don't know what the problem is, you can't find a solution! Once you know what

More information

Lecture 05 I/O statements Printf, Scanf Simple statements, Compound statements

Lecture 05 I/O statements Printf, Scanf Simple statements, Compound statements Programming, Data Structures and Algorithms Prof. Shankar Balachandran Department of Computer Science and Engineering Indian Institute of Technology, Madras Lecture 05 I/O statements Printf, Scanf Simple

More information

Physics REU Unix Tutorial

Physics REU Unix Tutorial Physics REU Unix Tutorial What is unix? Unix is an operating system. In simple terms, its the set of programs that makes a computer work. It can be broken down into three parts. (1) kernel: The component

More information

The Stack, Free Store, and Global Namespace

The Stack, Free Store, and Global Namespace Pointers This tutorial is my attempt at clarifying pointers for anyone still confused about them. Pointers are notoriously hard to grasp, so I thought I'd take a shot at explaining them. The more information

More information

4. Structure of a C++ program

4. Structure of a C++ program 4.1 Basic Structure 4. Structure of a C++ program The best way to learn a programming language is by writing programs. Typically, the first program beginners write is a program called "Hello World", which

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

Introduction to JavaScript and the Web

Introduction to JavaScript and the Web Introduction to JavaScript and the Web In this introductory chapter, we'll take a look at what JavaScript is, what it can do for you, and what you need to be able to use it. With these foundations in place,

More information

1 Getting used to Python

1 Getting used to Python 1 Getting used to Python We assume you know how to program in some language, but are new to Python. We'll use Java as an informal running comparative example. Here are what we think are the most important

More information

CS102: Standard I/O. %<flag(s)><width><precision><size>conversion-code

CS102: Standard I/O. %<flag(s)><width><precision><size>conversion-code CS102: Standard I/O Our next topic is standard input and standard output in C. The adjective "standard" when applied to "input" or "output" could be interpreted to mean "default". Typically, standard output

More information

The following content is provided under a Creative Commons license. Your support

The following content is provided under a Creative Commons license. Your support MITOCW Lecture 2 The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high quality educational resources for free. To make a donation

More information

MITOCW watch?v=rvrkt-jxvko

MITOCW watch?v=rvrkt-jxvko MITOCW watch?v=rvrkt-jxvko The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high quality educational resources for free. To

More information

Lesson 3 Transcript: Part 1 of 2 - Tools & Scripting

Lesson 3 Transcript: Part 1 of 2 - Tools & Scripting Lesson 3 Transcript: Part 1 of 2 - Tools & Scripting Slide 1: Cover Welcome to lesson 3 of the db2 on Campus lecture series. Today we're going to talk about tools and scripting, and this is part 1 of 2

More information

>print "hello" [a command in the Python programming language]

>print hello [a command in the Python programming language] What Is Programming? Programming is the process of writing the code of computer programs. A program is just a sequence of instructions that a computer is able to read and execute, to make something happen,

More information

Fortunately, you only need to know 10% of what's in the main page to get 90% of the benefit. This page will show you that 10%.

Fortunately, you only need to know 10% of what's in the main page to get 90% of the benefit. This page will show you that 10%. NAME DESCRIPTION perlreftut - Mark's very short tutorial about references One of the most important new features in Perl 5 was the capability to manage complicated data structures like multidimensional

More information

So on the survey, someone mentioned they wanted to work on heaps, and someone else mentioned they wanted to work on balanced binary search trees.

So on the survey, someone mentioned they wanted to work on heaps, and someone else mentioned they wanted to work on balanced binary search trees. So on the survey, someone mentioned they wanted to work on heaps, and someone else mentioned they wanted to work on balanced binary search trees. According to the 161 schedule, heaps were last week, hashing

More information

Master Syndication Gateway V2. User's Manual. Copyright Bontrager Connection LLC

Master Syndication Gateway V2. User's Manual. Copyright Bontrager Connection LLC Master Syndication Gateway V2 User's Manual Copyright 2005-2006 Bontrager Connection LLC 1 Introduction This document is formatted for A4 printer paper. A version formatted for letter size printer paper

More information

Scripting Languages. Diana Trandabăț

Scripting Languages. Diana Trandabăț Scripting Languages Diana Trandabăț Master in Computational Linguistics - 1 st year 2017-2018 Today s lecture What is Perl? How to install Perl? How to write Perl progams? How to run a Perl program? perl

More information

An attribute used in HTML that is used for web browsers screen reading devices to indicate the presence and description of an image Module 4

An attribute used in HTML that is used for web browsers screen reading devices to indicate the presence and description of an image Module 4 HTML Basics Key Terms Term Definition Introduced In A tag used in HTML that stands for Anchor and is used for all types of hyperlinks Module 3 A tag used in HTML to indicate a single line break

More information

A shell can be used in one of two ways:

A shell can be used in one of two ways: Shell Scripting 1 A shell can be used in one of two ways: A command interpreter, used interactively A programming language, to write shell scripts (your own custom commands) 2 If we have a set of commands

More information

Helping the Compiler Help You. Thomas Dy

Helping the Compiler Help You. Thomas Dy Helping the Compiler Help You Thomas Dy Programming do { programmer.write_code(); if(lazy) { sleep(); } compile_code(); } while(compiler.has_errors()); Compiler: Me no speaky English Programmer: Compiler,

More information

Let's Look Back. We talked about how to create a form in HTML. Forms are one way to interact with users

Let's Look Back. We talked about how to create a form in HTML. Forms are one way to interact with users Introduction to PHP Let's Look Back We talked about how to create a form in HTML Forms are one way to interact with users Users can enter information into forms which can be used by you (programmer) We

More information

Arduino IDE Friday, 26 October 2018

Arduino IDE Friday, 26 October 2018 Arduino IDE Friday, 26 October 2018 12:38 PM Looking Under The Hood Of The Arduino IDE FIND THE ARDUINO IDE DOWNLOAD First, jump on the internet with your favorite browser, and navigate to www.arduino.cc.

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

CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics. COMP-202 Unit 1: Introduction

CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics. COMP-202 Unit 1: Introduction CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics COMP-202 Unit 1: Introduction Announcements Did you miss the first lecture? Come talk to me after class. If you want

More information

We are assuming you have node installed!

We are assuming you have node installed! Node.js Hosting We are assuming you have node installed! This lesson assumes you've installed and are a bit familiar with JavaScript and node.js. If you do not have node, you can download and install it

More information

A PROGRAM IS A SEQUENCE of instructions that a computer can execute to

A PROGRAM IS A SEQUENCE of instructions that a computer can execute to A PROGRAM IS A SEQUENCE of instructions that a computer can execute to perform some task. A simple enough idea, but for the computer to make any use of the instructions, they must be written in a form

More information

The Perl Debugger. Avoiding Bugs with Warnings and Strict. Daniel Allen. Abstract

The Perl Debugger. Avoiding Bugs with Warnings and Strict. Daniel Allen. Abstract 1 of 8 6/18/2006 7:36 PM The Perl Debugger Daniel Allen Abstract Sticking in extra print statements is one way to debug your Perl code, but a full-featured debugger can give you more information. Debugging

More information

Shell Scripting. Todd Kelley CST8207 Todd Kelley 1

Shell Scripting. Todd Kelley CST8207 Todd Kelley 1 Shell Scripting Todd Kelley kelleyt@algonquincollege.com CST8207 Todd Kelley 1 If we have a set of commands that we want to run on a regular basis, we could write a script A script acts as a Linux command,

More information

A Big Step. Shell Scripts, I/O Redirection, Ownership and Permission Concepts, and Binary Numbers

A Big Step. Shell Scripts, I/O Redirection, Ownership and Permission Concepts, and Binary Numbers A Big Step Shell Scripts, I/O Redirection, Ownership and Permission Concepts, and Binary Numbers Copyright 2006 2009 Stewart Weiss What a shell really does Here is the scoop on shells. A shell is a program

More information

AHHHHHHH!!!! NOT TESTING! Anything but testing! Beat me, whip me, send me to Detroit, but don t make me write tests!

AHHHHHHH!!!! NOT TESTING! Anything but testing! Beat me, whip me, send me to Detroit, but don t make me write tests! NAME DESCRIPTION Test::Tutorial - A tutorial about writing really basic tests AHHHHHHH!!!! NOT TESTING! Anything but testing! Beat me, whip me, send me to Detroit, but don t make me write tests! *sob*

More information

Client Side JavaScript and AJAX

Client Side JavaScript and AJAX Client Side JavaScript and AJAX Client side javascript is JavaScript that runs in the browsers of people using your site. So far all the JavaScript code we've written runs on our node.js server. This is

More information

Blitz2D Newbies: Definitive Guide to Types by MutteringGoblin

Blitz2D Newbies: Definitive Guide to Types by MutteringGoblin Blitz2D Newbies: Definitive Guide to Types by MutteringGoblin Types are probably the hardest thing to understand about Blitz Basic. If you're using types for the first time, you've probably got an uneasy

More information

Setting up a ColdFusion Workstation

Setting up a ColdFusion Workstation Setting up a ColdFusion Workstation Draft Version Mark Mathis 2000 all rights reserved mark@teratech.com 2 Setting up a ColdFusion workstation Table of Contents Browsers:...5 Internet Explorer:...5 Web

More information

How to approach a computational problem

How to approach a computational problem How to approach a computational problem A lot of people find computer programming difficult, especially when they first get started with it. Sometimes the problems are problems specifically related to

More information

COMP2100/2500 Lecture 16: Shell Programming I

COMP2100/2500 Lecture 16: Shell Programming I [ANU] [DCS] [COMP2100/2500] [Description] [Schedule] [Lectures] [Labs] [Homework] [Assignments] [COMP2500] [Assessment] [PSP] [Java] [Reading] [Help] COMP2100/2500 Lecture 16: Shell Programming I Summary

More information

USQ/CSC2406 Web Publishing

USQ/CSC2406 Web Publishing USQ/CSC2406 Web Publishing Lecture 4: HTML Forms, Server & CGI Scripts Tralvex (Rex) Yeap 19 December 2002 Outline Quick Review on Lecture 3 Topic 7: HTML Forms Topic 8: Server & CGI Scripts Class Activity

More information

MITOCW watch?v=se4p7ivcune

MITOCW watch?v=se4p7ivcune MITOCW watch?v=se4p7ivcune The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high quality educational resources for free. To

More information

6.001 Notes: Section 8.1

6.001 Notes: Section 8.1 6.001 Notes: Section 8.1 Slide 8.1.1 In this lecture we are going to introduce a new data type, specifically to deal with symbols. This may sound a bit odd, but if you step back, you may realize that everything

More information

Class #7 Guidebook Page Expansion. By Ryan Stevenson

Class #7 Guidebook Page Expansion. By Ryan Stevenson Class #7 Guidebook Page Expansion By Ryan Stevenson Table of Contents 1. Class Purpose 2. Expansion Overview 3. Structure Changes 4. Traffic Funnel 5. Page Updates 6. Advertising Updates 7. Prepare for

More information

CS105 Perl: Perl CGI. Nathan Clement 24 Feb 2014

CS105 Perl: Perl CGI. Nathan Clement 24 Feb 2014 CS105 Perl: Perl CGI Nathan Clement 24 Feb 2014 Agenda We will cover some CGI basics, including Perl-specific CGI What is CGI? Server Architecture GET vs POST Preserving State in CGI URL Rewriting, Hidden

More information

package YourModule; require = = qw(munge frobnicate); # symbols to export on request

package YourModule; require = = qw(munge frobnicate); # symbols to export on request NAME SYNOPSIS Exporter - Implements default import method for modules In module YourModule.pm: require Exporter; @EXPORT_OK = qw(munge frobnicate); # symbols to export on request or use Exporter 'import';

More information

Lesson 1 using Dreamweaver CS3. To get started on your web page select the link below and copy (Save Picture As) the images to your image folder.

Lesson 1 using Dreamweaver CS3. To get started on your web page select the link below and copy (Save Picture As) the images to your image folder. Lesson 1 using Dreamweaver CS3 To get started on your web page select the link below and copy (Save Picture As) the images to your image folder. Click here to get images for your web page project. (Note:

More information

CMSC 201 Fall 2016 Lab 09 Advanced Debugging

CMSC 201 Fall 2016 Lab 09 Advanced Debugging CMSC 201 Fall 2016 Lab 09 Advanced Debugging Assignment: Lab 09 Advanced Debugging Due Date: During discussion Value: 10 points Part 1: Introduction to Errors Throughout this semester, we have been working

More information

You just told Matlab to create two strings of letters 'I have no idea what I m doing' and to name those strings str1 and str2.

You just told Matlab to create two strings of letters 'I have no idea what I m doing' and to name those strings str1 and str2. Chapter 2: Strings and Vectors str1 = 'this is all new to me' str2='i have no clue what I am doing' str1 = this is all new to me str2 = I have no clue what I am doing You just told Matlab to create two

More information

@EXPORT_OK = qw(munge frobnicate); # symbols to export on request

@EXPORT_OK = qw(munge frobnicate); # symbols to export on request NAME Exporter - Implements default import method for modules SYNOPSIS In module YourModule.pm: package YourModule; require Exporter; @ISA = qw(exporter); @EXPORT_OK = qw(munge frobnicate); # symbols to

More information

Troubleshooting Maple Worksheets: Common Problems

Troubleshooting Maple Worksheets: Common Problems Troubleshooting Maple Worksheets: Common Problems So you've seen plenty of worksheets that work just fine, but that doesn't always help you much when your worksheet isn't doing what you want it to. This

More information

Scripting. Shell Scripts, I/O Redirection, Ownership and Permission Concepts, and Binary Numbers

Scripting. Shell Scripts, I/O Redirection, Ownership and Permission Concepts, and Binary Numbers Scripting Shell Scripts, I/O Redirection, Ownership and Permission Concepts, and Binary Numbers Adapted from Practical Unix and Programming Hunter College Copyright 2006 2009 Stewart Weiss What a shell

More information

Developing Ajax Applications using EWD and Python. Tutorial: Part 2

Developing Ajax Applications using EWD and Python. Tutorial: Part 2 Developing Ajax Applications using EWD and Python Tutorial: Part 2 Chapter 1: A Logon Form Introduction This second part of our tutorial on developing Ajax applications using EWD and Python will carry

More information

Week - 01 Lecture - 04 Downloading and installing Python

Week - 01 Lecture - 04 Downloading and installing Python Programming, Data Structures and Algorithms in Python Prof. Madhavan Mukund Department of Computer Science and Engineering Indian Institute of Technology, Madras Week - 01 Lecture - 04 Downloading and

More information

The Very Basics of the R Interpreter

The Very Basics of the R Interpreter Chapter 2 The Very Basics of the R Interpreter OK, the computer is fired up. We have R installed. It is time to get started. 1. Start R by double-clicking on the R desktop icon. 2. Alternatively, open

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

Here we will look at some methods for checking data simply using JOSM. Some of the questions we are asking about our data are:

Here we will look at some methods for checking data simply using JOSM. Some of the questions we are asking about our data are: Validating for Missing Maps Using JOSM This document covers processes for checking data quality in OpenStreetMap, particularly in the context of Humanitarian OpenStreetMap Team and Red Cross Missing Maps

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

Hands-On Perl Scripting and CGI Programming

Hands-On Perl Scripting and CGI Programming Hands-On Course Description This hands on Perl programming course provides a thorough introduction to the Perl programming language, teaching attendees how to develop and maintain portable scripts useful

More information

Slide 1 Java Programming 1 Lecture 2D Java Mechanics Duration: 00:01:06 Advance mode: Auto

Slide 1 Java Programming 1 Lecture 2D Java Mechanics Duration: 00:01:06 Advance mode: Auto Java Programming 1 Lecture 2D Java Mechanics Slide 1 Java Programming 1 Lecture 2D Java Mechanics Duration: 00:01:06 To create your own Java programs, you follow a mechanical process, a well-defined set

More information

9.2 Linux Essentials Exam Objectives

9.2 Linux Essentials Exam Objectives 9.2 Linux Essentials Exam Objectives This chapter will cover the topics for the following Linux Essentials exam objectives: Topic 3: The Power of the Command Line (weight: 10) 3.3: Turning Commands into

More information

An Introduction to Maple This lab is adapted from a lab created by Bob Milnikel.

An Introduction to Maple This lab is adapted from a lab created by Bob Milnikel. Some quick tips for getting started with Maple: An Introduction to Maple This lab is adapted from a lab created by Bob Milnikel. [Even before we start, take note of the distinction between Tet mode and

More information

CSC105, Introduction to Computer Science I. Introduction. Perl Directions NOTE : It is also a good idea to

CSC105, Introduction to Computer Science I. Introduction. Perl Directions NOTE : It is also a good idea to CSC105, Introduction to Computer Science Lab03: Introducing Perl I. Introduction. [NOTE: This material assumes that you have reviewed Chapters 1, First Steps in Perl and 2, Working With Simple Values in

More information

MITOCW watch?v=9h6muyzjms0

MITOCW watch?v=9h6muyzjms0 MITOCW watch?v=9h6muyzjms0 The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high quality educational resources for free. To

More information

A function is a named piece of code that performs a specific task. Sometimes functions are called methods, procedures, or subroutines (like in LC-3).

A function is a named piece of code that performs a specific task. Sometimes functions are called methods, procedures, or subroutines (like in LC-3). CIT Intro to Computer Systems Lecture # (//) Functions As you probably know from your other programming courses, a key part of any modern programming language is the ability to create separate functions

More information

COSC 2206 Internet Tools. The HTTP Protocol

COSC 2206 Internet Tools. The HTTP Protocol COSC 2206 Internet Tools The HTTP Protocol http://www.w3.org/protocols/ What is TCP/IP? TCP: Transmission Control Protocol IP: Internet Protocol These network protocols provide a standard method for sending

More information

EVENT-DRIVEN PROGRAMMING

EVENT-DRIVEN PROGRAMMING LESSON 13 EVENT-DRIVEN PROGRAMMING This lesson shows how to package JavaScript code into self-defined functions. The code in a function is not executed until the function is called upon by name. This is

More information

NETB 329 Lecture 13 Python CGI Programming

NETB 329 Lecture 13 Python CGI Programming NETB 329 Lecture 13 Python CGI Programming 1 of 83 What is CGI? The Common Gateway Interface, or CGI, is a set of standards that define how information is exchanged between the web server and a custom

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

PROFESSOR: Last time, we took a look at an explicit control evaluator for Lisp, and that bridged the gap between

PROFESSOR: Last time, we took a look at an explicit control evaluator for Lisp, and that bridged the gap between MITOCW Lecture 10A [MUSIC PLAYING] PROFESSOR: Last time, we took a look at an explicit control evaluator for Lisp, and that bridged the gap between all these high-level languages like Lisp and the query

More information

Azon Master Class. By Ryan Stevenson Guidebook #5 WordPress Usage

Azon Master Class. By Ryan Stevenson   Guidebook #5 WordPress Usage Azon Master Class By Ryan Stevenson https://ryanstevensonplugins.com/ Guidebook #5 WordPress Usage Table of Contents 1. Widget Setup & Usage 2. WordPress Menu System 3. Categories, Posts & Tags 4. WordPress

More information

Anatomy of an HTML document

Anatomy of an HTML document Anatomy of an HTML document hello World hello World This is the DOCTYPE declaration.

More information

Linked Lists. What is a Linked List?

Linked Lists. What is a Linked List? Linked Lists Along with arrays, linked lists form the basis for pretty much every other data stucture out there. This makes learning and understand linked lists very important. They are also usually the

More information

Hello, and welcome to another episode of. Getting the Most Out of IBM U2. This is Kenny Brunel, and

Hello, and welcome to another episode of. Getting the Most Out of IBM U2. This is Kenny Brunel, and Hello, and welcome to another episode of Getting the Most Out of IBM U2. This is Kenny Brunel, and I'm your host for today's episode which introduces wintegrate version 6.1. First of all, I've got a guest

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

The name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet.

The name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet. Mr G s Java Jive #2: Yo! Our First Program With this handout you ll write your first program, which we ll call Yo. Programs, Classes, and Objects, Oh My! People regularly refer to Java as a language that

More information

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG 1 Notice Reading Assignment Chapter 1: Introduction to Java Programming Homework 1 It is due this coming Sunday

More information

Shorthand for values: variables

Shorthand for values: variables Chapter 2 Shorthand for values: variables 2.1 Defining a variable You ve typed a lot of expressions into the computer involving pictures, but every time you need a different picture, you ve needed to find

More information

Introduction to Unix

Introduction to Unix Introduction to Unix Part 1: Navigating directories First we download the directory called "Fisher" from Carmen. This directory contains a sample from the Fisher corpus. The Fisher corpus is a collection

More information

1 Output and static... variables 2 Modifying variables Sophisticated... variables: arrays 4 Sophisticated...

1 Output and static... variables 2 Modifying variables Sophisticated... variables: arrays 4 Sophisticated... Contents I Table of Contents Part I Document Overview 2 Part II What is Perl? 3 Part III Getting Started with Simple Examples 4 1 Output and static... variables 4 2 Modifying variables... 4 3 Sophisticated...

More information

Hi everyone. Starting this week I'm going to make a couple tweaks to how section is run. The first thing is that I'm going to go over all the slides

Hi everyone. Starting this week I'm going to make a couple tweaks to how section is run. The first thing is that I'm going to go over all the slides Hi everyone. Starting this week I'm going to make a couple tweaks to how section is run. The first thing is that I'm going to go over all the slides for both problems first, and let you guys code them

More information

Formal Methods of Software Design, Eric Hehner, segment 1 page 1 out of 5

Formal Methods of Software Design, Eric Hehner, segment 1 page 1 out of 5 Formal Methods of Software Design, Eric Hehner, segment 1 page 1 out of 5 [talking head] Formal Methods of Software Engineering means the use of mathematics as an aid to writing programs. Before we can

More information

GLY Geostatistics Fall Lecture 2 Introduction to the Basics of MATLAB. Command Window & Environment

GLY Geostatistics Fall Lecture 2 Introduction to the Basics of MATLAB. Command Window & Environment GLY 6932 - Geostatistics Fall 2011 Lecture 2 Introduction to the Basics of MATLAB MATLAB is a contraction of Matrix Laboratory, and as you'll soon see, matrices are fundamental to everything in the MATLAB

More information

Week 5 Lecture 3. Compiler Errors

Week 5 Lecture 3. Compiler Errors Lecture 3 Compiler Errors Agile Development Backlog of stories defines projects Backlog contains all of the requirements currently known Stories define features of the project Three elements: feature user,

More information

Hello World! Computer Programming for Kids and Other Beginners. Chapter 1. by Warren Sande and Carter Sande. Copyright 2009 Manning Publications

Hello World! Computer Programming for Kids and Other Beginners. Chapter 1. by Warren Sande and Carter Sande. Copyright 2009 Manning Publications Hello World! Computer Programming for Kids and Other Beginners by Warren Sande and Carter Sande Chapter 1 Copyright 2009 Manning Publications brief contents Preface xiii Acknowledgments xix About this

More information

Java Programming Fundamentals - Day Instructor: Jason Yoon Website:

Java Programming Fundamentals - Day Instructor: Jason Yoon Website: Java Programming Fundamentals - Day 1 07.09.2016 Instructor: Jason Yoon Website: http://mryoon.weebly.com Quick Advice Before We Get Started Java is not the same as javascript! Don t get them confused

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

What is PHP? [1] Figure 1 [1]

What is PHP? [1] Figure 1 [1] PHP What is PHP? [1] PHP is an acronym for "PHP: Hypertext Preprocessor" PHP is a widely-used, open source scripting language PHP scripts are executed on the server PHP is free to download and use Figure

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

Learning to Program with Haiku

Learning to Program with Haiku Learning to Program with Haiku Lesson 4 Written by DarkWyrm All material 2010 DarkWyrm It would be incredibly hard to write anything useful if there weren't ways for our programs to make decisions or to

More information

Ruby on Rails Welcome. Using the exercise files

Ruby on Rails Welcome. Using the exercise files Ruby on Rails Welcome Welcome to Ruby on Rails Essential Training. In this course, we're going to learn the popular open source web development framework. We will walk through each part of the framework,

More information

Dynamic Documents. Kent State University Dept. of Math & Computer Science. CS 4/55231 Internet Engineering. What is a Script?

Dynamic Documents. Kent State University Dept. of Math & Computer Science. CS 4/55231 Internet Engineering. What is a Script? CS 4/55231 Internet Engineering Kent State University Dept. of Math & Computer Science LECT-12 Dynamic Documents 1 2 Why Dynamic Documents are needed? There are many situations when customization of the

More information

First Java Program - Output to the Screen

First Java Program - Output to the Screen First Java Program - Output to the Screen These notes are written assuming that the reader has never programmed in Java, but has programmed in another language in the past. In any language, one of the

More information

IDM 232. Scripting for Interactive Digital Media II. IDM 232: Scripting for IDM II 1

IDM 232. Scripting for Interactive Digital Media II. IDM 232: Scripting for IDM II 1 IDM 232 Scripting for Interactive Digital Media II IDM 232: Scripting for IDM II 1 PHP HTML-embedded scripting language IDM 232: Scripting for IDM II 2 Before we dive into code, it's important to understand

More information

Web technologies. Web. basic components. embellishments in browser. DOM (document object model)

Web technologies. Web. basic components. embellishments in browser. DOM (document object model) Web technologies DOM (document object model) what's on the page and how it can be manipulated forms / CGI (common gateway interface) extract info from a form, create a page, send it back server side code

More information