- 论坛徽章:
- 0
|
本帖最后由 txh_zyy 于 2015-01-13 17:53 编辑
用 pp 打包可执行文件命令如下:执行t1.exe报错信息:- Use of uninitialized value $myname in concatenation (.) or string at script/t1.pl line 16.
- DBI connect('dbname=script/../db/a.sqlite','',...) failed: unable to open database file at script/t1.pl line 21
复制代码 问题感觉就是pp打包完了,无法执行abs_path来动态获取路径,还有一个就是无法打开a.sqlite文件,不知哪位有对这方面有经验的帮帮忙?
测试代码如下:- #!/usr/bin/perl
- use strict;
- use warnings;
- use DBI;
- use DBD::SQLite;
- use File::Basename qw(dirname);
- use Cwd 'abs_path';
- my $conf_filename = '/etc/t1.pl.conf';
- unless ( $conf_filename and -s $conf_filename ) {
- print "Usage: t1.pl /etc/t1.pl.conf\n";
- exit;
- }
- chdir dirname(__FILE__);
- my $myname = abs_path(__FILE__);
- $0 = "$myname $conf_filename";
- print $0, "\n";
- my $dbname = dirname(__FILE__) . "/../db/a.sqlite";
- my $dsn = "DBI:SQLite:dbname=$dbname";
- my $dbh = DBI->connect( $dsn, "", "", { 'RaiseError' => 1 } );
复制代码 |
|