我有Solaris 10,我正在尝试运行Perl程序。
我安装了两个perl版本:
版本5.8.4的 /usr/bin/perl
和
版本5.12.3的 /usr/local/bin/perl
我已经安装了DBI软件包(它已安装在这里,/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';
答案 0 :(得分:6)
你没有为/ usr / bin / perl安装Time :: Piece,所以安装它。
/usr/bin/perl -MCPAN -e install Time::Piece
您没有为/ usr / local / bin / perl安装DBI,因此请安装它。
/usr/local/bin/perl -MCPAN -e install DBI