Advanced Topics Web Programming.

Slides:



Advertisements
Similar presentations
Widhy Hayuhardhika NP, S.Kom. Overview of database structure Connecting to MySQL database Selecting the database to use Using the require_once statement.
Advertisements

Programming MySQL, Perl COEN 351. Reading List Paul DuBois: MySQL and Perl for the Web, New Riders, 2002 Jacqueline D. Hamilton: CGI Programming 101,
NEVUG - August 2004 To Boldly Go: Using Perl and the Perl DBI as an Adjunct to MS Access for Custom Reports Maggie Rioux MBLWHOI Library Woods Hole, Mass.
Murali Mani SQL-PL Interface. Murali Mani Some Possible Options Web Interface Perl /CGI with Oracle/mySQL Install your own web server and use servlets.
W EB A PPLICATION D EVELOPMENT A PPLICATION T O B IO -I NFORMATICS -III Vicky Khanna M-Tech Bioinformatics.
Perl Functions Learning Objectives: 1. To learn how to create functions in a Perl’s program & how to call them 2. To learn how to pass [structured] arguments.
M.P. Johnson, DBMS, Stern/NYU, Spring C : Database Management Systems Lecture #21 M.P. Johnson Stern School of Business, NYU Spring, 2005.
20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 8: Perl Basics Fundamentals of Web Programming.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 25 – Perl and CGI (Common Gateway Interface) Outline 25.1 Introduction 25.2 Perl 25.3 String Processing.
CSE S. Tanimoto Perl Arrays, Functions, Lists, Refs, Etc 1 Perl: Arrays, Functions, References, Etc. Arrays Slices, splices Contexts: list, scalar.
PHP Programming. Topics Background and History of PHP Installation Comments in PHP Variables Conditions Loops Functions File Handling Database Handling.
1 Spidering the Web in Python CSC 161: The Art of Programming Prof. Henry Kautz 11/23/2009.
Set 5: Perl and Database Connections
Student Learning Environment on the World Wide Web l CGI-programming in Perl for the connection of databases over the Internet. l Web authoring using Frontpage.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
(Chapter 10 continued) Our examples feature MySQL as the database engine. It's open source and free. It's fully featured. And it's platform independent.
Templates, Databases and Frameworks. Databases: DBI Common database interface for perl Provides a functional,
Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
Databases On The Web with perl Archie Warnock
Just a Little PHP Programming PHP on the Server. Common Programming Language Features Comments Data Types Variable Declarations Expressions Flow of Control.
7 1 User-Defined Functions CGI/Perl Programming By Diane Zak.
Chapter 15 Introduction to PL/SQL. Chapter Objectives  Explain the benefits of using PL/SQL blocks versus several SQL statements  Identify the sections.
Perl Modules Darby Tien-Hao Chang Department of Electrical Engineering, National Cheng Kung University.
Copyright © 2003 ProsoftTraining. All rights reserved. Perl Fundamentals.
ECMM6018 Enterprise Networking for Electronic Commerce Tutorial 7
Copyright 2007 Byrne Reese. Distributed under Creative Commons, share and share alike with attribution. Intermediate Perl Programming Class Four Instructor:
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.
Copyright 2007 Byrne Reese. Distributed under Creative Commons, share and share alike with attribution. Intermediate Perl Programming Class Three Instructor:
Perl Variables: Array Web Programming1. Review: Perl Variables Scalar ► e.g. $var1 = “Mary”; $var2= 1; ► holds number, character, string Array ► e.g.
CP476 Internet Computing Perl CGI and MySql 1 Relational Databases –A database is a collection of data organized to allow relatively easy access for retrievals,
Perl Day 6. Multiline Strings Perl supports a mechanism to deal with multiple lines of text rather than having to add them one at a time Perl supports.
DBI: The Neophyte's Guide1 What is DBI? DBI = DataBase Interface DBI is database-independent DBI allows you to write code that interacts with databases.
 History  Ease of use  Portability  Standard  Security & Privacy  User support  Application &Popularity Today  Ten Most Popular Programming Languages.
Dept. of Animal Breeding and Genetics Programming basics & introduction to PERL Mats Pettersson.
1 Using Perl Modules. 2 What are Perl modules?  Modules are collections of subroutines  Encapsulate code for a related set of processes  End in.pm.
COMP234 - perl Perl DBI Topics Database vs access methods DBMS and DBMS API's Relational database SEQUEL Perl DBI SQL.
LING/C SC/PSYC 438/538 Lecture 5 Sandiway Fong.
Web Database Programming Using PHP
Internet/Web Databases
Section 6.3 Server-side Scripting
© 2016, Mike Murach & Associates, Inc.
Intermediate Perl - References
Web Database Programming Using PHP
DBW - PHP DBW2017.
Server-Side Application and Data Management IT IS 3105 (Spring 2010)
LING/C SC/PSYC 438/538 Lecture 7 Sandiway Fong.
Perl: Functions, References, Etc.
Data Representation – Instructions
Perl Database – Just Enough
Web Systems Development (CSC-215)
Perl Variables: Array Web Programming.
Subroutines Web Programming.
Perl: Arrays, Functions, References, Etc.
Perl Variables: Hash Web Programming.
Perl: Arrays, Functions, References, Etc.
Basic Input/Output Web Programming.
CGI II: Cookies & Stuff Web Programming.
Web DB Programming: PHP
Server-Side Processing II
Perl: Arrays, Functions, References, Etc.
What is Perl? PERL--Practical Extraction and Report Language
Chapter 7 Searching Your Products
Lecture 5: Functions and Parameters
Perl: Arrays, Functions, References, Etc.
More Variables and Data Types: references/matricies
Linked Lists.
Perl: Arrays, Functions, References, Etc.
Database SQL.
CGI II: Cookies & Stuff Web Programming.
CGI II: Cookies & Stuff Web Programming.
Presentation transcript:

Advanced Topics Web Programming

Reference/Pointer A reference Syntax a pointer to something (e.g. array, hash) a variable that refer to other variables contain a memory address of data good for working with large data structures creating complex data structures Syntax to create a reference $ptr1= \$scalar; $ptr2= \@array; $ptr3= \%hash; $ptr4= [1, 2, 3]; $ptr5= { k1=>v1, k2=>v2} to get the value Variable (i.e. scalar, array, hash) $$ptr1; @$ptr2; %$ptr3; Element of array/hash $$ptr2[0]; $$ptr3{0}; $ptr2->[0]; $ptr3->{0}; Web Programming

Multi-dimensional Arrays Using anonymous arrays $array = [ [id1,pw1], [id2,pw2], [id3,pw3] ]; for ($i=0; $i<=2; $i++) { for ($j=0; $j<=1; $j++) { print “$array -> [i][j]\n”; } Using array references @a1= (id1,pw1); @a2= (id2,pw2); @a3= (id3,pw3); @array = (\@a1, \@a2, \@a3); # array of array pointers for ($i=0; $i<=2; $i++) { $ptr= $array[$i]; print “@$ptr\n”; Examples: #1, #2, #3, #4, #5 Web Programming

Fetching Web pages with LWP use LWP::Simple; $url= http://ella.slis.indiana.edu/~kiyang/hello.htm; $body= get($url); print $body; Example script use LWP::UserAgent; $ua = LWP::UserAgent->new(); $resp= $ua->get($url); $content=$resp->content(); print $content; Example script Form CGI Web Programming

WWW-Mechanize Module a subclass of LWP::UserAgent Basics Create a mech use WWW::Mechanize; my $mech = WWW::Mechanize->new( autocheck => 1 ); Fetch a page $mech->get( "http://ella.slis.indiana.edu/~kiyang/hello.htm" ); print $mech->content; Fetch a page into a file $mech->get( " http://ella.slis.indiana.edu/~kiyang/hello.htm", ":content_file" => “hello.htm" ); Get Links @links= $mech->links(); # @links: array of link object foreach $link(@links) { my($url,$text,$absurl)= ($link->url(), $link->text, $link->url_abs()); print “$url, $text, $absurl\n”; } Find Links $link= $mech->find_link(url_abs_regex=>qr|^http://ella.slis.indiana.edu|); $page= $mech->follow_link(url_abs_regex=>qr|^http://ella.slis.indiana.edu|); @pages= $mech->follow_all_links(url_abs_regex=>qr|^http://ella.slis.indiana.edu|); Mechanized Spider Example: #1, #2, #3 Web Programming

Perl DBI Module Basics Connect to a database Execute SQL Retrieve data use DBI; my $dbh = DBI->connect( DBI:Pg:dbname=$dbname; host=$host; $user, $pw ) || die “Can’t connect to DB: $DBI::errstr\n”; Execute SQL my $sql = “SELECT * FROM $table; my $sth = $dbh->prepare($sql); $sth->execute(); Retrieve data while (@row= $sth->fetchrow_array()) {; print join (“, “,@row),”\n”; } Disconnect from the database $dbh->disconnect(); Example Script: #1, #2 Perl DBI Manual Web Programming

Miscellaneous Features require “mylib.pl” store and use common subroutines in mylib.pl looks for mylib.pl in @INC directory add “return 1” at the end of “mylib.pl” example: mylib.pl, calling script #1 perlcc prog.pl –o prog.out generates a compiled binary named “prog.out” Web Programming