我有Solaris 10,我試圖運行一個Perl程序。無法運行perl程序:無法找到@INC中的Time/Piece.pm,使用perl5.8.4,無法在@INC中使用perl查找DBI.pm 5.12.3
我已經安裝了兩個版本的Perl:5.8.4
和
版本5.12.3
我已經安裝了DBI包/usr/local/bin/perl
(它得到安裝
的版本/usr/bin/perl
在這裏,/usr/perl5/site_perl/5.8.4/sun4-solaris-64int/auto/DBI/.packlist
),我通過執行不同的perl
版本的Perl程序得到的問題是(在Ubuntu的工作正常)。
bash-3.00# perl temp.pl Can't locate Time/Piece.pm in @INC (@INC contains: /usr/perl5/5.8.4/lib/sun4- solaris-64int /usr/perl5/5.8.4/lib /usr/perl5/site_perl/5.8.4/sun4-solaris-64int /usr/perl5/site_perl/5.8.4 /usr/perl5/site_perl /usr/perl5/vendor_perl/5.8.4/sun4- solaris-64int /usr/perl5/vendor_perl/5.8.4 /usr/perl5/vendor_perl .) at temp.pl line 4. BEGIN failed--compilation aborted at temp.pl line 4. bash-3.00# /usr/local/bin/perl temp.pl Can't locate DBI.pm in @INC (@INC contains: /usr/local/lib/perl5/site_perl/5.12.3 /sun4-solaris /usr/local/lib/perl5/site_perl/5.12.3 /usr/local/lib/perl5/5.12.3/sun4- solaris /usr/local/lib/perl5/5.12.3 /usr/local/lib/perl5/site_perl .) at temp.pl line5. BEGIN failed--compilation aborted at temp.pl line 5.
我已經嘗試過很多方法,但沒有得到如何在solaris上運行我的Perl程序。 請人請幫忙。
下面是我的程序。實際上它是由@Borodin重新定義的。非常感謝他。
use strict;
use warnings;
use Time::Piece;
use DBI;
open my $log, '<', '/opt/testlogs/test.log' or die "Unable to open log file: $!";
my ($count_start, $count_interim, $count_stop) = (0, 0, 0);
while (<$log>) {
if (/server start/) {
$count_start++;
}
elsif (/server interim-update/) {
$count_interim++;
}
elsif (/server stop/) {
$count_stop++;
}
}
print <<END;
Start: $count_start
Interim: $count_interim
Stop: $count_stop
END
print localtime->strftime("%b %e %H:%M:%S"), "\n";
my $dbh = DBI->connect("DBI:Pg:dbname=postgres;host=localhost", "postgres", "postgres", { 'RaiseError' => 1 });
my $rows = $dbh->do(
"insert into radius (server_start, server_stop, server_interim)
Values ($count_start, $count_stop, $count_interim)"
);
printf "%d %s affected\n", $rows, $rows == 1 ? 'row' : 'rows';
從[堆棧溢出的Perl FAQ](http://stackoverflow.com/questions/tagged/perl?sort=faq):?什麼是安裝缺少的Perl模塊最簡單的方法(HTTP: //stackoverflow.com/questions/65865/whats-the-easiest-way-to-install-a-missing-perl-module) – daxim 2012-07-19 17:25:35