gpt4 book ai didi

perl - 无法使用 perl5.8.4 在 @INC 中运行 perl 程序 : Can't locate Time/Piece. pm 并且无法使用 perl 5.12.3 在 @INC 中找到 DBI.pm

转载 作者:行者123 更新时间:2023-12-01 22:41:59 25 4
gpt4 key购买 nike

<分区>

我有 Solaris 10,我正在尝试运行 Perl 程序。

我安装了两个 perl 版本:

/usr/bin/perl 版本 5.8.4

/usr/local/bin/perl 版本 5.12.3

我已经安装了 DBI 包(它安装在这里,/usr/perl5/site_perl/5.8.4/sun4-solaris-64int/auto/DBI/.packlist),问题我通过使用不同的 perl 版本执行 Perl 程序来获得(在 ubuntu 中它工作正常)。

bash-3.00# perl temp.plCan'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.plCan'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.

I have tried hell lot of ways but not getting how to run my Perl program on solaris.Could anybody help please.

Below is my program. In fact it was redefined by @Borodin. Thanks a lot to him.

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';

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com