Lecture #1 Introduction to Perl Introduction Perl Is Acronym Of

Lecture #1 Introduction to Perl Introduction Perl Is Acronym Of

Lecture #1 Introduction to Perl Introduction Perl is acronym of “Practical Extraction and Report Language”. It is a scripting language developed by Larry Wall in the late 1987 as a Unix-based report language. However, it has evolved to be one fo the popular Web programming languages. According to the Perl.org site, which develops and maintains the language, Perl is “intended to be practical (easy to use, efficient, complete) rather than beautiful (tiny, elegant, minimal). Its major features are that it is easy to use, supports both procedural and object-oriented (OO) programming, has powerful built-in support for text processing, and “has one of the world’s most impressive collections of third-party modules.” As of the time this lecture note is written, Perl 5 is the latest stable version. The latest major stable revision of Perl 5 is 5.24.0, which is released in May 09, 2016. There is, however, Perl 6 which is still under development. According to the Perl.org web site, Perl 6 is a sister language, part of the Perl family, not intended as a replacement for Perl 5, but as its own thing - libraries exist to allow you to call Perl 5 code from Perl 6 programs and vice versa. The final release date of Perl 6 is unknown. Tools need for Perl is not part of Windows operating system. Students using Windows OS need to built the this class “toolkit” individually in order to complete all the learning activities of this course. The toolkit includes: (a) a Perl distribution, (b) a web server, (c) a generic text editor, and (d) an optional but recommended USB flash drive (with 2GB of free speace). While a nearly-zero cost solution is provided by the instructor as part of the learning activities in this lecture, this section will explain why the toolkit is required. Perl distribution is available for a wide variety of platforms, including Windows, Linux, and Mac. This lecture note is written based on Windows operating systesm. Students will need to download the either the 32-bit or 64-bit binary code applicable for their platforms and install Perl. The official site to download Perl is http://www.perl.org/. Due to the need to discuss Perl for Web programming, the instructor chooses to use XAMPP which is a handy tool with Perl included. XAMPP is an open-source web server package that works on various platforms. It is actually an acronym with X meaning “cross” platform, “A” for Apache HTTP server, “M” for MySQL, “P” for PHP, and “P” for Perl. XAMPP was designed to help webpage developers, programmers, and designers check and review their work using their computers even without connection to the web or internet. The latest version of XAMPP is available for downloading at https://www.apachefriends.org/index.html. By the way, the entire XAMPP can be installed into and executed from a USB flash drive. = Apache + MySQL + PHP + PERL 1 The good news is: Perl can run in most major operating systems, including Linux/ Unix, Microsoft Windows, Mac OS X, and others. Perl also supports most of the web server software including Apache, Microsoft Internet Information Server, Personal Web Server, Netscape, iPlanet servers, and many others. However, it is not techinically practical for the instructor to provide every student a functional Web server. In the past, students need to download and install a Web server application, such as Apache. Then, each student need to: (a) download and install Perl installer, (b) activate supports for Perl, and (c) modify the server’s configuration files in order to recognize Perl script files before they can write and test Perl scripts. On the other hands, in order to learn how a Perl server works with MySQL server in order to build a data-driven site, students also need to download and install the MySQL software, which is a popular choice of database management system (DBMS) used in the World Wide Web. Thanks to the generosity of ApacheFriends.org which provides XAMPP for free, students are now able to execute PHP scripts without all the above mentioned preparations. XAMPP is a free and open source cross-platform web server package, consisting mainly of the Apache HTTP Server, MySQL database, and interpreters for scripts written in the Perl. Throughout this course, students will be using XAMPP to test and execute Perl scripts. The lastest version of XAMPP can be downloaded at https://www.apachefriends.org/. With XAMPP installed, each student’s personal computer (including laptop) becomes an individual web server that can interpret PHP codes and is able to execute query statements to retrieve data from a MySQL database. XAMPP = client + Web server + PERL server + MySQL server The following figure illustrates the role MySQL plays. Perl scripts is the intermediary between the web browser and the MySQL server. The browser is the data requester, while MySQL is the data provider. The communication between the browser and the web server is handled by Perl. Likewise, the communication between the web server and MySQL is done by Perl as well. Interestingly, the user interface between the user (human) and the web server must be defined with HTML (Hypertext Markup Language), which is a standardized system for tagging text files to achieve font, color, graphic, and hyperlink effects on World Wide Web pages. dynamic web web content data web manipulation browser MySQL HTTP request server database In a nutshell, a dynamic web site can be constructed by using Perl to build the application, while using HTML to define the web content layouts. The following illustrates the relationship between Perl and HTML. One can say that HTML is at the human layer, while Perl is only at the Perl. The good news is: Throughout this course, students will focus on the learning of Perl coding, not the building of fancy-looking web sites using HTML and CSS (cascade style sheet). After all, this is a web programming course, not a web development course. 2 In a nutshell, a dynamic web site can be constructed by using Perl to build the application, while using HTML to define the web content layouts. The following illustrates the relationship between PERL and HTML. One can say that HTML is at the human layer, while Perl is only at the Perl. The good news is: Throughout this course, students will focus on the learning of PERL coding, not the building of fancy-looking web sites using HTML and CSS (cascade style sheet). After all, this is a web programming course, not a web development course. HTML human user PERL machine In this class, due to the barriers for the instructor to build a server that allows students to upload scripts and test these scripts with the server, XAMPP is probably the best alternative. Students will install a copy of XAMPP, which is a scaled-down version of Apache Web server, on a local machine (or a USB flash drive). The next few sections will discuss how Perl dynamically generate output for command-line interfaces (such as the Microsoft Command Prompt and Linux Terminal) and web broswers. By the way, a command line interface (cli) is a user interface to a computer’s operating system or an application in which the user responds to a visual prompt by typing in a command on a specified line, receives a response back from the system, and then enters another command, and so forth. Throughout this course, the instructor chooses to use Microsft Command Prompt for demonstration. Microsoft Windows [Version 10.0.14393] (c) 2016 Microsoft Corporation. All rights reserved. C:\Users\user> As a matter of fact, programmers can run Perl from a graphical user interface (GUI) environment as well. Some use Padre (a Perl IDE); others use Eclipse Plugin EPIC (Perl Editor and IDE for Eclipse if you are familiar with Eclipse). However, throughout this course, a generic text editor like Microsoft Notepad is good enough. Perl supports several file extensions; however, programmers typically use .pl for regular Stand- alone Perl scripts and .pl or .cgi for Web scripts, while Perl modules use .pm. A Perl “module” is a set of related functions in a single library file with .pm extensions. Throughout this course, students will mainly create stand-alone Perl scripts use the .pl extension. What is a Perl Perl is a scripting language. All Perl programs do not need to be compiled into self-excutable program? programs (such as .exe). They stay as text-based script files designed to be read by the Perl interpreter. Each time when a Perl script is called for execution, it is the Perl interpreter that converts the script file contents to machine codes (binary codes). The text-to-binary convesrsion is done each time when the script files are read. Unlike most programming languages (such as C++), Perl script files are not required to be compiled into self-executable programs. However, there are some utilities that can compile Perl scripts into standalong executables (read for http://www.nicholassolutions.com/tutorials/perl-PAR.htm details). The following figure illustrates how a Perl script is interpreted and its two possibly routines of output. 3 Command-line interface Perl Perl scripts interpret Web server Web browser (Apache) (GUI) In a nutshell, Perl scripts perform a combination of three primary tasks, Inpute, Processing, and Output, known as the I-P-O model. The following is a simple Perl script that performs both processing and output. It generates a text message as output: Hello, world!. In this program, the instructor did not use any control structure (such as if..else or for loop); therefore, all its statements will be read sequentially (in a line-by-line manner).

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    37 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us