Đầu trang

Danh sách Khóa học > Lập Trình Perl CGI

  • Lập Trình Perl CGI

Thời lượng 48 giờ / Học phí 3,200,000

Perl (viết tắt của Practical Extraction and Report Language - ngôn ngữ kết xuất và báo cáo thực dụng) được Larry Wall xây dựng từ năm 1987, với mục đích chính là tạo ra mộtngôn ngữ lập trình có khả năng chắt lọc một lượng lớn dữ liệu và cho phép xử lí dữ liệu nhằm thu được kết quả cần tìm.

Perl là ngôn ngữ thông dụng trong lĩnh vực quản trị hệ thống và xử lí các trang Web do có các ưu điểm sau:

  • Có các thao tác quản lí tập tin, xử lí thông tin thuận tiện
  • Thao tác với chuỗi kí tự rất tốt
  • Đã có một thư viện mã lệnh lớn do cộng đồng sử dụng Perl đóng góp (CPAN).

Cú pháp lệnh của Perl khá giống với C , từ các kí hiệu đến tên các hàm, do đó, nhiều người (đã có kinh nghiệm với C) thấy Perl dễ học. Perl khá linh hoạt và cho phép người sử dụng giải quyết với cùng một vấn đề được đặt ra theo nhiều cách khác nhau.

Nội dung chương trình:

  • Introduction
  • Introducing Perl and CGI
    • Origins of the language
    • The difference between Perl and CGI
    • The relationship between Perl and HTML
    • Understanding the Web browser-Web server relationship
    • Installing and configuring Perl for your environment
      • Will be customized to Windows, MacOS X, Linux, Solaris, or another operating system based on the attendees' server platform
    • Extending Perl's functionality with modules
    • The roles of CGI.pm and DBI.pm
  • Perl building blocks
    • Perl data
    • Operations and functions
    • Quotation marks
    • Quoting without quotes
    • Statements, blocks, and scope
    • Declaring private variables
    • The "shebang" line
    • Creating a Perl CGI script
    • Creating output for a browser
    • Documenting your script
    • Checking the script's syntax
  • Getting data from visitors (can be accelerated or skipped if attendees are fluently familiar with HTML forms)
    • Labeling incoming data
    • Creating a form
    • Creating:
      • Text boxes
      • Password fields
      • Text areas
      • Radio buttons
      • Check boxes
      • Select lists and menus
      • Submit and reset buttons
      • Image buttons
    • Specifying the action of the form
    • Understanding form methods: GET vs. POST
    • How your script processes data from a form
    • How your script processes data passed via a hyperlink
  • Environment variables
    • Your visitor's browser and platform
    • Viewing available environment variables
    • Storing data from environment variables
  • Getting data into the script
    • Getting single-value form data
    • Getting multiple-value form data
    • Getting the names of all form elements
    • Retrieving values from each of these elements
  • Simple operations with scalar variables
    • What is a scalar variable?
    • Assigning a value to a scalar
    • Multiplying, dividing, adding, subtracting
    • Using more than one operators
    • Raising a number to an exponential power
    • Using mathematical functions
    • Concatenating (joining) strings
    • Repeating a string
    • Operating and assigning in one step
    • Incrementing or decrementing a variable
  • Conditionals and loops
    • Comparing numbers
    • Comparing strings
    • Evaluating conditions without comparisons
    • Testing two or more comparisons at a time
    • Creating a basic conditional statement
    • Adding options for false conditions
    • Adding multiple, independent conditions
    • Using unless
    • Loop structures:
      • while and until
      • for
      • foreach
    • Using break to exit a loop
    • Using continue to start the next iteration of a loop
  • Working with arrays
    • Assigning a list to an array variable
    • Referring to a particular item in an array
    • Referring to multiple items from an array
    • Using shift(), unshift(), push(), pop(), and splice() to add, remove, or replace items in an array
    • Using sort() and reverse() to change the order of an array
    • Using length() to determine how many elements are in the array
  • Subroutines
    • Why create subroutines?
    • Using a simple subroutine
    • Creating and calling subroutines
    • Processing values passed to a subroutine
    • Returning a value from a subroutine
    • Storing subroutines in a separate file
    • Loading subroutines from a separate file
  • Working with hashes
    • Why use hashes?
    • Assigning a list to a hash
    • Getting a value using a key
    • Adding or replacing a key-value pair
    • Getting several values using keys
    • Getting all of a hash's keys
    • Getting all of a hash's values
    • Getting each key and value in a hash
    • Getting pairs in a specified order
    • Removing key-value pairs
  • Analyzing data and validating form submissions
    • Why analyze data?
    • In-depth primer on regular expressions, which enable simple or complex patterns to be detected within text strings
    • Finding something
    • Finding and replacing
    • Seeing and using what was found
    • Splitting a value into pieces
    • Constructing search patterns
    • Matching a single character
    • Matching a string of characters
    • Matching a character from a group
    • Matching a character that's not in the group
    • Using class shorthands
    • Advanced regular expression techniques
    • Form validation
      • Client-side, server-side, or both?
      • Defining validation rules and analyzing submitted data
      • Returning messages back to the user about whether their form submission is valid or invalid
  • Remembering what visitors tell you
    • Overview of strategies for maintaining user information and application state
    • Using hidden fields to store and pass data
    • Using cookies to store and pass data
      • Setting a cookie
      • Restricting a cookie by domain and/or path
      • Setting the expiration of a cookie
      • Requiring the presence of a secure connection
      • Retrieving and working with cookie values
      • What to do when a user's browser refuses to accept a cookie
  • Formatting output
    • Formatting output with Perl
    • Creating a format pattern for integers
    • Creating a format pattern for non-integers
    • Creating a pattern for strings
    • Changing case
    • Changing characters
    • Finding the length of a string
    • Extracting one string from another
    • Cleaning up the end of a string
  • Formatting output with HTML
    • Overview of CGI.pm's capabilities for automatically-generating HTML
    • Generating the HTTP header
    • Using start_html() to generate the document head
    • Concluding the page with end_html()
    • Dynamically generating text and tables of text
    • Dynamically generating hyperlinks and images
    • Dynamically generating forms
    • Styling output with CSS
  • Introduction to CGI/Perl security
    • Reading the security FAQs
    • The problem with visitor input
    • Protecting calls to the system
    • Limiting access to files
    • Using CGI.pm to limit incoming data
    • Keeping information to yourself
    • Avoiding tainted data
    • Cleaning and using outside data
  • Files and directories
    • Opening a file
    • Verifying file and directory operations
    • Writing to an external file
    • Getting exclusive access to a file
    • Reading data from an external file
    • Closing a file
    • Renaming or removing a file
    • Checking a file's status
    • Opening, reading from, and closing directories
    • Changing the working directory
    • Creating a directory
    • Changing permissions from within a script
    • Removing a directory
  • Generating email messages from your scripts
    • Routing data from Perl to mail, sendmail, or another application or module that will mail it
    • Important security considerations
    • Adding file attachments
  • Processing file uploads
    • Why upload files via HTML forms?
    • Setting the enctype and method of the form to facilitate uploads
    • Defining one or more file fields in the form
    • Controlling where the uploaded file is saved
    • Preventing common security issues that can arise when saving uploaded files
  • Database connectivity: introducing the DBI module
    • Origins of DBI, the database interface module
    • DBI architecture
    • Overview of available DBDs (database drivers)
    • Setting up and configuring DBI and DBDs
  • Selecting records from the database via ad hoc queries
    • Building a SQL SELECT statement
    • Sending the SQL statement to the database for execution
    • Displaying a single value returned from the database
    • Displaying multiple rows of data returned from the database
    • Handling errors that can occur when interacting with the database
  • Inserting, updating, and deleting records
    • Building SQL INSERT, UPDATE, and DELETE statements
    • Building Web-based interfaces for inserting, updating, and deleting database records
    • Validating user input
    • Prompting the user for confirmation
    • Grouping related operations together as transactions so that they either all succeed or all fail
  • Invoking stored procedures
    • Why use stored procedures instead of ad hoc SQL queries?
    • Defining stored procedures
    • Invoking stored procedures
    • Passing input parameters to stored procedures
    • Retrieving output parameters from stored procedures
    • Handling in/out parameters
  • Finding, downloading, and installing additional Perl modules from CPAN (the Comprehensive Perl Archive Network)
  • Conclusion