Basic Input/Output Web Programming.

Slides:



Advertisements
Similar presentations
Adding Dynamic Content to your Web Site
Advertisements

Computer Programming for Biologists Class 9 Dec 4 th, 2014 Karsten Hokamp
Input from STDIN STDIN, standard input, comes from the keyboard. STDIN can also be used with file re-direction from the command line. For instance, if.
6a.1 More about files: Globbing. 6a.2 Open a file for reading, and link it to a filehandle: open(IN, "
CS 898N – Advanced World Wide Web Technologies Lecture 8: PERL Chin-Chih Chang
Perl File I/O Learning Objectives: 1. To understand the usage of file handler in Perl 2. To learn the file error handling / testing in Perl.
Introduction to Perl Learning Objectives: 1. To introduce the features provided by Perl 2. To learn the basic Syntax & simple Input/Output control in Perl.
Introduction to Perl. How to run perl Perl is an interpreted language. This means you run it through an interpreter, not a compiler. Your program/script.
CSC3530 Software Technology Tutorial Two PERL Basics.
1ex.1 Perl Programming for Biology Exercise 1 The Bioinformatics Unit G.S. Wise Faculty of Life Science Tel Aviv University, Israel March 2009 Eyal Privman.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 6P. 1Winter Quarter I/O in C Lecture 6.
I/O while ($line= ){ #remove new line char \n chomp($line); if($line eq “quit”){ exit(1); } while ( ){ #remove new line char \n chomp($_); if($_ eq “quit”){
Guide To UNIX Using Linux Third Edition
File/Directory manipulation. Opening a File To read from a file, must use a file handle. –by convention, all caps open a file (for reading): –open FILE,
Lecture 8: Basic concepts of subroutines. Functions In perl functions take the following format: – sub subname – { my $var1 = $_[0]; statements Return.
Practical Extraction & Report Language PERL Joseph Beltran.
Meet Perl, Part 2 Flow of Control and I/O. Perl Statements Lots of different ways to write similar statements –Can make your code look more like natural.
Bioinformatics Introduction to Perl. Introduction What is Perl Basic concepts in Perl syntax: – variables, strings, – Use of strict (explicit variables)
Introduction to Perl Yupu Liang cbio at MSKCC
7 1 User-Defined Functions CGI/Perl Programming By Diane Zak.
3.1 Revision: variables & arrays Array declaration Array = ('A','B','C','D'); = = (); Array.
ENG College of Engineering Engineering Education Innovation Center 1 Array Accessing and Strings in MATLAB Topics Covered: 1.Array addressing. 2.
Introduction to Perl “Practical Extraction and Report Language” “Pathologically Eclectic Rubbish Lister”
5 1 Data Files CGI/Perl Programming By Diane Zak.
Artificial Intelligence Lecture No. 26 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
Perl COEN 351  Thomas Schwarz, S.J Perl Scripting Language Developed by Larry Wall 1987 to speed up system administration tasks. Design principles.
Department of Electrical and Computer Engineering Introduction to Perl By Hector M Lugo-Cordero August 26, 2008.
Introduction to Perl. What is Perl Perl is an interpreted language. This means you run it through an interpreter, not a compiler. Similar to shell script.
Basic Variables & Operators Web Programming1. Review: Perl Basics Syntax ► Comments: start with # (ignored by Perl) ► Statements: ends with ; (performed.
1 Homework Done the reading? –K&R –Glass Chapters 1 and 2 Applied for cs240? (If not, keep at it!) Gotten a UNIX account? (If not, keep at it!)
Python – May 12 Recap lab Chapter 2 –operators –Strings –Lists –Control structures.
Perl Variables: Array Web Programming1. Review: Perl Variables Scalar ► e.g. $var1 = “Mary”; $var2= 1; ► holds number, character, string Array ► e.g.
1 PHP Intro PHP Introduction After this lecture, you should be able to: Know the fundamental concepts of Web Scripting Languages in general, PHP in particular.
Perl Scripting II Conditionals, Logical operators, Loops, and File handles Suzi Lewis Genome Informatics.
File Handle and conditional Lecture 2. File Handling The Files associated with Perl are often text files: e.g. text1.txt Files need to be “opened for.
PZ02CX Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ02CX - Perl Programming Language Design and Implementation.
Bioinformatics Introduction to Perl. Introduction What is Perl Basic concepts in Perl syntax: – variables, strings, – Use of strict (explicit variables)
Introduction to Programming the WWW I CMSC Winter 2003 Lecture 17.
CPTG286K Programming - Perl Chapter 9: Misc. Control Structures Chapter 10: Filehandles & File tests.
CS 403: Programming Languages Lecture 20 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
Lesson 11. CGI CGI is the interface between a Web page or browser and a Web server that is running a certain program/script. The CGI (Common Gateway Interface)
CIRC Summer School 2016 Baowei Liu
Input from STDIN STDIN, standard input, comes from the keyboard.
Perl Programming Language Design and Implementation (4th Edition)
Programming Basics Web Programming.
CSE 303 Concepts and Tools for Software Development
User Defined Functions
Command Line Arguments
Advanced Topics Web Programming.
Perl Variables: Array Web Programming.
Control Structures: if Conditional
C Programming Lecture-15 File I/O
Subroutines Web Programming.
Structured Program Design
Perl Variables: Hash Web Programming.
Unit-2 Objects and Classes
An Introduction to Perl
Control Structures: for & while Loops
Context.
Lesson 2. Control structures File IO - reading and writing Subroutines
Programming Perls* Objective: To introduce students to the perl language. Perl is a language for getting your job done. Making Easy Things Easy & Hard.
Perl I/O Learning Objectives:
Line at a time I/O with fgets() and fputs()
Lab 4: Introduction to Scripting
The Selection Structure
Introduction to Perl Learning Objectives:
INTRODUCTION to PERL PART 1.
Karan Thaker CS 265 Section 001
LING/C SC/PSYC 438/538 Lecture 4 Sandiway Fong.
Presentation transcript:

Basic Input/Output Web Programming

Review: Perl Basics Perl Variables Standard Input Standard Output Scalar  holds number, character, string e.g. $var1 = “Mary”; $var2= 1; Array  holds a list of scalars e.g. @array1 = (“Mary”,”Tom”); Standard Input <STDIN>  reads 1 line from standard input e.g., $line= <STDIN>; Standard Output print  writes to standard output e.g., print “My name is $name\n”; Web Programming

File Input/Output Reading from a file Writing to a file open (INF,”$file1”); # open $file1 for reading $line = <INF>; # read in one line Writing to a file open (OUTF, “>$file2”); # open $file2 for writing open (OUTF, “>>$file2”); # open $file2 for appending print OUTF “This is line1\n”; # print to $file2 Closing a file after reading/writing close (FILE); Terminating program for bad file I/O open (FILE,$file) || die “can’t read $file”;  Example script Web Programming

Determining File Status Syntax if ( -test $file ) { statements } File test operators -d : Is $file a directory? -e : Does $file exist? -f : Is $file is an ordinary file? -l : Is $file a symbolic link? -s : Is $file a non-empty file? -z : Is $file an empty file? -r/-w/-x : Is $file readable/writable/executable?  Example script Web Programming

Working with Directories Open a directory opendir (IND, $directory); Read the contents. @files = readdir (IND); Close the directory closedir (IND);  Example script Web Programming