Objective
Take over predecessors of the project, no contact, installation, use of Perl and dbd::oracle, there is no relevant documentation, blankly at a loss ~ ~. At the beginning of the problem, thinking about the rapid resolution, directly on Google search error messages, the process of searching found that if not clear the cause and the cause I can't even see the solution "do not understand." So we need to add this knowledge and think about solutions. The following is my side of the process of learning to solve the problem, if not enough, please the big guys point out.
Error
Install_driver (Oracle) Failed:can ' t locate dbd/oracle.pm in @INC (@INC contains:/home/as_user/pms/data-update/usr/ local/lib64/perl5/usr/local/share/perl5/usr/lib64/perl5/vendor_perl/usr/share/perl5/vendor_perl/usr/lib64/ Perl5/usr/share/perl5.) at (eval) Line 3. Perhaps the Dbd::oracle Perl module hasn ' t been fully installed, or perhaps the capitalisation of ' Oracle ' isn ' t right. Available drivers:dbm, Examplep, File, Gofer, Pg, Proxy, SQLite, Sponge, MySQL. at/home/as_user/pms/data-update/solexadown.pl Line 19
DBI Related knowledge
Reference: Rookie tutorial DBI related
How to use DBI in Perl
1 # 2 use DBI; # Perl introduces the DBI module 3 $dbh = Dbi->connect ("dbi:oracle:host=$host; sid=$sid$user$ passwd); # DBI invokes the corresponding data module based on the handle of the input driver object, returning a handle to the database object
There are two problems in my mind at this time.
1. Using use in the code, how to know the directory where DBI, where set, and @inc have what relationship???
2.DBI How to activate dbd::oracle, look for the path is what, where, how to set, and @inc what is the relationship???
The above problem may be found in the configuration dbd::oracle, so I will first query learning the configuration process
Configuration Method Dbd::oracle
Reference: Linux environment configuration Dbd::oracle module
Points
1. The Dbd::oracle module is not officially developed by Oracle, developed by Pythian Group and is https://metacpan.org/pod/DBD::Oracle, and the address of the module is downloaded https:// Metacpan.org/release/mjevans/dbd-oracle-1.75_2. Of course you can go to Cpan (Comprehensive Perl Archive Network,perl module Aggregation library https://www.cpan.org/) download
2. First load DBI, then the DBD module, in the installation of Dbd::oracle, if installed on a host without Oracle database, you need to install the Oracle Instant Client for remote database connection
3. In the installation tutorial, it is indicated that to configure the Orcale_home directory, we can enter the VI BASHRC command in the root directory to see the configuration information of Oracle_home.
During the installation of the dbd::oracle process, setting the Oracle_home variable seems to be related to my question 2, but there is no relationship with the 11 point, it is doubtful that Perl has set the corresponding parameters, carefully look at the beginning of the execution script, found that the use of Findbin, If you don't know what to do, learn it. Fortunately, in the process of learning to solve my doubts and errors.
Perl's Findbin module (be sure to look at the reference URL, very helpful)
Point 1:
Reference: Perl uses the Findbin module to solve path problems in scripts
Assuming the script path is/home/as_user/pms/testt.pl, run the script under directory/home/as_user/pms
That is, $bin represents the path/home/as_user/pms, $Script represents testt.pl
Point 2:
Reference: Understanding how to use Use_require_do
Use is in the default @inc to find the corresponding module, once the module is not in the @inc, then use is not introduced. The name that is introduced with use does not need a suffix, and is only available by default. PM File
Point 3:
Reference: View Perl module Installation path
@INC is a special list scalar of Perl that stores the path of the current version of the Perl module. When compiling the script, Perl will query the module that the user calls according to the path of the @inc store, can use the command ' perl-v ' to view the directory of the specific module, also can use the begin code block to operate the @inc. Where. Represents the current directory of the script.
Summarize
After learning the ' configuration Dbd::oracle method ' and ' Perl's Findbin module ' related knowledge, then return to the error, error said in @inc path can ' t locate dbd/oracle.pm, since cannot find, then we want to set the DBD in the execution script The path of the/oracle.pm. The method of setting is to use the Findbin module.
For example: Execute script solexadown.pl directory is/home/as_user/pms/data-update, in this directory under the/lib directory exists dbd/oracle.pm, that is, the existence of a path/home/as_user/pms/ data-update/dbd/oracle.pm. So I'm at the beginning of the olexadown.pl script, it should be written on
Use ' $Bin ' ; Use " $Bin/lib ";
That way, Perl can find dbd/oracle.pm when it executes the solexadown.pl script. The problem solved ~ ~
In the Linux CentOS environment, Perl uses dbd::oracle to encounter the error can ' t locate dbdoracle.pm in @INC solution