Web Development in Perl
-
Upload
naveen-gupta -
Category
Technology
-
view
27.042 -
download
3
description
Transcript of Web Development in Perl
![Page 1: Web Development in Perl](https://reader035.fdocuments.in/reader035/viewer/2022081513/55583248d8b42ac6078b461a/html5/thumbnails/1.jpg)
April 12, 2023 Naveen Gupta 1
Web Development in Perl
WEB DEVELOPMENT IN Perl
Naveen Gupta [email protected]
![Page 2: Web Development in Perl](https://reader035.fdocuments.in/reader035/viewer/2022081513/55583248d8b42ac6078b461a/html5/thumbnails/2.jpg)
April 12, 2023 Naveen Gupta 2
Web Development in Perl
• AGENDA
– Introduction to Web Development & Perl– Perl Powered Sites/Application– Basic Web Programming in Perl– CGI Programming in Perl– Creating HTML Forms– mod_perl– Templating Systems in Perl– Web 2.0 Applications in Perl– Perl vs PHP - A Tale of 2 Languages
![Page 3: Web Development in Perl](https://reader035.fdocuments.in/reader035/viewer/2022081513/55583248d8b42ac6078b461a/html5/thumbnails/3.jpg)
April 12, 2023 Naveen Gupta 3
Web Development in Perl
• Introduction to Web Development
What is Web Dev? – Development of websites, internet applications, e-
commerce sites, social networks etc.
– Includes Web Designing, Content Development, client/server side coding, Web Server configuration
– Flexible Model, easy to adopt to, Barriers to entry very low
– Contributing Factors - Propagation of Open Source Technologies, WYSIWYG Tools, Internet Awareness
– Killer Apps – Google Docs, Flickr, WordPress, PhpBB, WikiMedia, YouTube and millions others
![Page 4: Web Development in Perl](https://reader035.fdocuments.in/reader035/viewer/2022081513/55583248d8b42ac6078b461a/html5/thumbnails/4.jpg)
April 12, 2023 Naveen Gupta 4
Web Development in Perl
• Dominant Technologies
– C, C++, Pascal, Shell Script– ASP– JAVA, J2EE and related Frameworks– Perl with or without CGI– PHP– .NET – C#, VB.NET– Python– Ruby on Rails– ColdFusion
![Page 5: Web Development in Perl](https://reader035.fdocuments.in/reader035/viewer/2022081513/55583248d8b42ac6078b461a/html5/thumbnails/5.jpg)
April 12, 2023 Naveen Gupta 5
Web Development in Perl
• Introduction to Perl
– Created by Larry Wall in 1987– Interpreted, Scripting Language– C - like syntax– Best of C, awk and sed– Best language for Text Manipulation/ Data Processing– Swiss Army knife for SysAdmins, Programmers– Supports modules, OO, DB interaction, pointers, regular
expressions, multithreading, sockets, MVC frameworks– Highly Portable, well documented
![Page 6: Web Development in Perl](https://reader035.fdocuments.in/reader035/viewer/2022081513/55583248d8b42ac6078b461a/html5/thumbnails/6.jpg)
April 12, 2023 Naveen Gupta 6
Web Development in Perl
• Perl and the WEB
– De facto language for CGI Programs– Made popular by Matt’s Script Archive– Easy to build and maintain– Wide acceptance of LAMP framework – Linux, Apache, MySQL,
PHP/Perl/Python/Ruby– Great DB support via DBI set of Modules– Strength of Perl – CPAN, Comprehensive Perl Archive
Network– Hands down winner with the advent of mod_perl, FastCGI,
Catalyst, Moose etc.
![Page 7: Web Development in Perl](https://reader035.fdocuments.in/reader035/viewer/2022081513/55583248d8b42ac6078b461a/html5/thumbnails/7.jpg)
April 12, 2023 Naveen Gupta 7
Web Development in Perl
• How to get Perl?
- For *NIX Platforms – Included with almost every Linux, BSD, Solaris, OS X installation. Source can be can be downloaded from http://www.perl.org and compiled using “gcc”. RPMs are also available.
- For Windows Platforms – Installation Binary distributed by http://www.activestate.com as ActivePerl. Yet, complete LAMP installations distributed by http://www.apachefriends.org, http://www.apache.org, http://www.indigostar.com etc. are most popular. Complete listing can be found at http://www.perl.org/ports
![Page 8: Web Development in Perl](https://reader035.fdocuments.in/reader035/viewer/2022081513/55583248d8b42ac6078b461a/html5/thumbnails/8.jpg)
April 12, 2023 Naveen Gupta 8
Web Development in Perl
Perl Powered Sites/Applications
![Page 9: Web Development in Perl](https://reader035.fdocuments.in/reader035/viewer/2022081513/55583248d8b42ac6078b461a/html5/thumbnails/9.jpg)
April 12, 2023 Naveen Gupta 9
Web Development in Perl
My First Web Program in Perl
#!/usr/bin/perl
print “Content-type:/text/html\n\n”;
print “Hello World!<br>”;
![Page 10: Web Development in Perl](https://reader035.fdocuments.in/reader035/viewer/2022081513/55583248d8b42ac6078b461a/html5/thumbnails/10.jpg)
April 12, 2023 Naveen Gupta 10
Web Development in Perl
Adding a Bit of `Perl`
#!/usr/bin/perl
print “Content-type:/text/html\n\n”;
my $time=localtime(time);
print “Today is $time <br>”;
foreach my $key (sort keys %ENV){print qq{$key = $ENV{$key} <br>};
}
![Page 11: Web Development in Perl](https://reader035.fdocuments.in/reader035/viewer/2022081513/55583248d8b42ac6078b461a/html5/thumbnails/11.jpg)
April 12, 2023 Naveen Gupta 11
Web Development in Perl
Jazz it up with a little HTML
#!/usr/bin/perl
print “Content-type:/text/html\n\n”;
print “<h1>Welcome to my First Perl Web page</h1>”;print “Perl is a great language!<br>”;print “It can create killer websites too!<br>”;print “Wanna see how?”;
![Page 12: Web Development in Perl](https://reader035.fdocuments.in/reader035/viewer/2022081513/55583248d8b42ac6078b461a/html5/thumbnails/12.jpg)
April 12, 2023 Naveen Gupta 12
Web Development in Perl
Here Document
#!/usr/bin/perl
print “Content-type:/text/html\n\n”;
print<<HTML;
<h1>Welcome to my First Perl Web page</h1>Perl is a great language!<br>It can create killer websites too!<br>Wanna see how?
HTML
![Page 13: Web Development in Perl](https://reader035.fdocuments.in/reader035/viewer/2022081513/55583248d8b42ac6078b461a/html5/thumbnails/13.jpg)
April 12, 2023 Naveen Gupta 13
Web Development in Perl
Going Dynamic with CGI#!/usr/bin/perl
use CGI;use strict;
my $cgi=new CGI;
print $cgi->header();print $cgi->start_html(-title=>’First CGI.pm program’, -meta=>{‘keywords’=>’perl cgi’, ‘copyright’=>’WebOSS ‘07’}, -style=>{‘src’=>’style.css’}, -BGCOLOR=>’blue’);
contd….
![Page 14: Web Development in Perl](https://reader035.fdocuments.in/reader035/viewer/2022081513/55583248d8b42ac6078b461a/html5/thumbnails/14.jpg)
April 12, 2023 Naveen Gupta 14
Web Development in Perl
…contd
Going Dynamic with CGI
print $cgi->h1(“Welcome to a CGI APP!”);print “Your IP Address is : ”.$ENV{‘REMOTE_ADDR’}.“<br>”;print “You have been directed here from:
$ENV{‘HTTP_REFERER’}” ;print $cgi->a({-href=>’http://search.cpan.org’, -target=>’_blank’}, “Go to CPAN!”);print $cgi->end_html;
![Page 15: Web Development in Perl](https://reader035.fdocuments.in/reader035/viewer/2022081513/55583248d8b42ac6078b461a/html5/thumbnails/15.jpg)
April 12, 2023 Naveen Gupta 15
Web Development in Perl
• The Power of mod_perl“…mod_perl is more than CGI scripting on steroids. It is a whole new way to create dynamic content by utilizing the full power of the Apache web server to create stateful sessions, customized user authentication systems, smart proxies and much more. Yet, magically, your old CGI scripts will continue to work and work very fast indeed. With mod_perl you give up nothing and gain so much! …” – Lincoln Stein, Author – CGI.pm
- Perl Interpreter embedded in Apache
- Overcomes one-process-per-request limitation of CGI, 100x faster!
- Write Apache modules in Perl instead of C
- Hundreds of Modules available in CPAN
- Numerous Application Frameworks, Templating Systems
- Configure Apache’s httpd.conf via Perl
![Page 16: Web Development in Perl](https://reader035.fdocuments.in/reader035/viewer/2022081513/55583248d8b42ac6078b461a/html5/thumbnails/16.jpg)
April 12, 2023 Naveen Gupta 16
Web Development in Perl
• Perl Templating Systems
– HTML::Mason
– Template Toolkit
– HTML::Template
– SSI using mod_include or Apache::SSI module
Why use Templating System?
• Consistency of Appearance
• Reusability
• Abstraction between logic and design
• Division of Labour
![Page 17: Web Development in Perl](https://reader035.fdocuments.in/reader035/viewer/2022081513/55583248d8b42ac6078b461a/html5/thumbnails/17.jpg)
April 12, 2023 Naveen Gupta 17
Web Development in Perl
• Web 2.0 Apps in Perl CGI::Ajax
• Object Oriented module by Brian C. Thomas
• Eliminates the need to write JS for AJAX Calls
• Generates JS Functions from output by Perl subroutines
• Can be implemented in large projects
HTML::TagCloud
• Generates Tag Clouds, with different font sizes
• CSS Based
• Add method takes 3 arguments – a) Tag Name
b) URL to link to
c) Weight
![Page 18: Web Development in Perl](https://reader035.fdocuments.in/reader035/viewer/2022081513/55583248d8b42ac6078b461a/html5/thumbnails/18.jpg)
April 12, 2023 Naveen Gupta 18
Web Development in Perl
WEB DEVELOPMENT IN Perl
Perl vs PHP
![Page 19: Web Development in Perl](https://reader035.fdocuments.in/reader035/viewer/2022081513/55583248d8b42ac6078b461a/html5/thumbnails/19.jpg)
April 12, 2023 Naveen Gupta 19
Web Development in Perl
Perl PHPPURPOSE/
UTILITYMulti-purpose, primarily for text
pocessing, equally suited for sysadmin and web apps
Made primarily for WEB. Can do CLI and other tasks.
LEARNING CURVE
Easier than C, JAVA, .NET Easier than Perl
API/ LIBRARY SUPPORT
48606 active modules on CPAN and many others elsewhere
PEAR and PECL, both from http://www.php.net
DOCUMENTATION
Perldoc, http://perldoc.perl.org , CPAN
http://www.php.net
APACHE INTEGRATION
mod_perl, Fast CGI mod_php
![Page 20: Web Development in Perl](https://reader035.fdocuments.in/reader035/viewer/2022081513/55583248d8b42ac6078b461a/html5/thumbnails/20.jpg)
April 12, 2023 Naveen Gupta 20
Web Development in Perl
Perl PHP
HTML EMBED Only with Modules like Mason, HTML::Template,
Template::Toolkit etc.
Yes, the main reason for its popularity
CMS / APPLICATIONS
AWStats, Slash Code, BugZilla WordPress, phpBB, Drupal, Coppermine,
phpMyAdmin
![Page 21: Web Development in Perl](https://reader035.fdocuments.in/reader035/viewer/2022081513/55583248d8b42ac6078b461a/html5/thumbnails/21.jpg)
April 12, 2023 Naveen Gupta 21
Web Development in Perl
THANK YOU!
use Perl;