Features of Perl scripts

Source: Internet
Author: User
Tags mysql variables versions client perl script

This chapter describes how to use the Perl DBI with the MySQL interface. We do not discuss the rationale or architecture of DBI. For information on these aspects of DBI (especially the comparison with the C and PHP APIs), see Chapter 5th.
Examples of this chapter use the sample database samp_db, using the credits save scheme and the tables required by the History League. To get the most out of this chapter, it's a good idea to know something about Perl. If you don't want to, it helps to copy the sample code you see here, and you can write your own script, but finding a good Perl book may still be a valuable investment. There is a book called "Programming Perl", and the second edition was written by WA l L, C H R i s t i a n s e N, Schwartz and P o T ter (o ' Reilly Publishing house 19 9 6). (Machinery Industry Publishing House, 1999, has published the "Perl 5 programming detailed"-Editor's note. )
The current version of DBI is 1. 13, but most of the introductions here are also available for earlier versions of 1.XX. Note that features that are not present in earlier versions of the description are described.
MySQL's dbi needs to be at least a 5.004_05 version of Perl. You must also install the Msql-mysql module and the Data-dumper Perl module, as well as the MYSQLC client library and some header files. If you plan to write web-based DBI scripts, use the CGI.PM module. In this chapter, this module is used to connect to the Apache Web server. Such as
If you need to obtain such packages, see Appendix A. The appendix also gives instructions for obtaining the sample scripts developed in this chapter. You can download these scripts without typing them yourself.
To a large extent, this chapter describes the methods and variables of Perl DBI for discussion purposes only. For a more comprehensive list of all methods and variables, see Appendix G. If any part of the DBI is to be used, the appendix may be used as a background material for further study. You can get the online documentation by running the following command:
% Perldoc DBI
% Perldoc Dbi::faq
% Perldoc Dbi::mysql at the database driver (DB D) level, the MySQL driver is based on the MYSQLC client library, and thus has some of its features. For more information about this library, see Chapter 6th.

Perl scripts are text files that can be created using any text editor. All of the Perl scripts in this chapter comply with the UNIX conventions, and the first line is ' #! ' Start, followed by the path name of the program to be used to execute the script. The first line looks like this:
#! /usr/bin/perl
If the path name is not perl in your system, such as/USR/LOCAL/BIN/PERL5 or/O p t/b i n/per L, you need to modify ' #! ' Yes. Otherwise, Perl scripts cannot run correctly in the system.
In ' #! ' Then it contains a space, because some systems will ' #! ' /' interpreted as a 4-byte weird number, so if there are no spaces, ignore the line, so that the script is treated as a shell script.
In a UNIX system, you should make the Perl script executable so that you can simply type its name to execute. To make the script executable, make the following changes to the file mode:
% chmod +x Script_name
If you are using ActiveState Perl under Windows, you do not have to make the script executable, but you can run a script as follows:
C:\> Perl Script_name

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.