2012-07-19 2 views
1

Solaris 10을 사용하고 있습니다. 펄 프로그램.perl 프로그램을 실행할 수 없습니다 : Perl5.8.4를 사용하여 @INC에서 Time/Piece.pm을 찾을 수없고 perl을 사용하여 @INC에서 DBI.pm을 찾을 수 없음 5.12.3

가 나는 두 펄 버전을 설치 한 : 버전의

/usr/bin/perl은 5.8.4

와 나는 DBI 패키지를 설치 한 5.12.3

버전의

/usr/local/bin/perl

(가 설치되어있어 여기, /usr/perl5/site_perl/5.8.4/sun4-solaris-64int/auto/DBI/.packlist), 다른 perl 버전의 Perl 프로그램을 실행하면 얻을 수있는 문제는 (우분투에서는 잘 작동합니다.)

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

(http://stackoverflow.com/questions/tagged/perl?sort=faq) [? 누락 된 펄 모듈을 설치하는 가장 쉬운 방법은 무엇 (HTTP : //stackoverflow.com/questions/65865/whats-the-easiest-way-to-install-a-missing-perl-module) – daxim

답변

5

/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 
+0

"당신"입니다. :-) – jimtut

+0

@jimtut, 감사합니다. 그것은 지금 고쳤다. (* 윙크 *) – ikegami

+0

Perl 프로그램에서 한 번 더 수동으로 찾아야 만 할 곳이 있습니다. 그래서 나는이 코드 행을 넣어야 만했다. : use perl :/home/el/perl5/lib/perl5/x86_64-linux-thread-multi "; 프로그램. 명령을 실행하여 사용할 경로를 찾을 수있었습니다 :'locate Piece.pm' –

관련 문제