[英]perl not able to connect database
I am new in perl programming. 我是Perl编程的新手。 I have tried the basic perl database connection and get the below error. 我尝试了基本的perl数据库连接,并得到以下错误。 Please any one help how to fix the issue. 请任何人帮助如何解决此问题。
"use" not allowed in expression at ./database.pl line 4, at end of line
syntax error at ./database.pl line 4, near "use DBI
use strict"
Execution of ./database.pl aborted due to compilation errors.
database.pl file database.pl文件
#!/usr/bin/perl
use DBI
use strict;
my $driver = "mysql";
my $database = "pj_order";
my $dsn = "DBI:$driver:database=$database;host=localhost";
my $userid = "root";
my $password = "root";
my $dbh = DBI->connect($dsn, $userid, $password ) or die $DBI::errstr;
Finally i have run the database.pl file and get the below error. 最后,我已经运行了database.pl文件,并得到以下错误。
"use" not allowed in expression at ./database.pl line 4, at end of line
syntax error at ./database.pl line 4, near "use DBI
use strict"
Execution of ./database.pl aborted due to compilation errors.
use DBI
should be 应该
use DBI;
It's probably best if you place it after 最好放在之后
use strict;
You should also have 你还应该有
use warnings qw( all );
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.