`
sillycat
  • 浏览: 2539105 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

Perl Project Improvement(1) Perl Installation and CPAN

 
阅读更多
Perl Project Improvement(1) Perl Installation and CPAN
> perl -v
This is perl 5, version 16, subversion 0 (v5.16.0) built for darwin-2level

CPAN installation
Log::Log4perl
YAML::XS
Data::Dumper
DBI
IOC
Redis
Time::Piece
Path::Class
autodie
Thread::Queue
DBD::mysql
threads

If CPAN install is not working, you may need force install.

1 Install DBI on MAC
>cpan App::cpanminus
> cpanm DBI
> perl -MCPAN -e 'shell'
cpan> get DBD::mysql

>cd  /usr/local/lib
> sudo ln -s /usr/local/mysql/lib/*.dylib .
> cd ~/.cpan/build/DBD*/
> sudo perl Makefile.PL --testuser='test'
sudo make and sudo make install
> sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/local/lib/libmysqlclient.18.dylib
> export DLYD_LIBRARY_PATH=/usr/local/mysql/lib

Show the Perl Directory:
> perl -e 'print join ("\n", @INC) . "\n";'
/home/ec2-user/perl5/lib/perl5/x86_64-linux-thread-multi
/home/ec2-user/perl5/lib/perl5
/usr/local/lib64/perl5
/usr/local/share/perl5
/usr/lib64/perl5/vendor_perl
/usr/share/perl5/vendor_perl
/usr/lib64/perl5
/usr/share/perl5
.

Run the Perl test cases
> prove t/*

2 Manually Install Perl
http://perldoc.perl.org/perlmacosx.html
http://www.cpan.org/src/
> curl -O http://www.cpan.org/src/perl-5.22.0.tar.gz
> ./Configure -des -Dprefix=/Users/carl/tool/perl-5.22.0
Make and Make Install

Build with supporting for threads
> ./Configure -des -Dusethreads -Dprefix=/Users/carl/tool/perl-5.22.0

threads and forks
http://stackoverflow.com/questions/22036985/error-using-thread-module-this-perl-not-built-to-support-threads

I checked the version on all the servers, I am using this old version.
> perl -v
This is perl 5, version 16, subversion 3 (v5.16.3) built for x86_64-linux-thread-multi
(with 25 registered patches, see perl -V for more detail)

So I will manually install the version on CentOS Docker Image

3 Manually Install Perl on CentOS Docker Image
> wget http://www.cpan.org/src/5.0/perl-5.16.3.tar.gz
> ./Configure -des -Dprefix=/tool/perl-5.16.3

Error Message:
I can't find make or gmake, and my life depends on it.
Go find a public domain implementation or fix your PATH setting!

Solution:
yum install -y gcc
yum install -y make

https://github.com/luohuazju/sillycat-docker/blob/master/centos7-nginx/Dockerfile

> make
> make install

If we install that on docker image, we can ignore the -Dprefix, because we do not want to set up PATH.

This can by pass the CPAN command confirmation.
export PERL_MM_USE_DEFAULT=1

cpan -fi Log::Log4perl YAML::XS

cpan -fi Log::Log4perl YAML::XS Data::Dumper DBI IOC Redis Time::Piece Path::Class autodie Thread::Queue DBD::mysql threads

cpan DBIx::Connector

or

cpan DBIx::Connector Log::Log4perl

cpan -fi autodie Thread::Queue threads

Install cpanm
> curl -L https://cpanmin.us | perl - App::cpanminus

Or
cpan App::cpanminus

Even this does not work
> cpanm --notest DBD::mysql

Error Message:
Can't exec "mysql_config": No such file or directory at Makefile.PL line 73.

Cannot find the file 'mysql_config'! Your execution PATH doesn't seem
not contain the path to mysql_config. Resorting to guessed values!

Solution:
yum install mysql-devel

The docker file configurations are as follow
Dockerfile
#Prepre the OS
FROM            centos:7
MAINTAINER      Carl Luo <luohuazju@gmail.com>

ENV             DEBIAN_FRONTEND noninteractive
ENV             PERL_MM_USE_DEFAULT 1

RUN             yum install -y gcc make wget
RUN             yum install -y mysql-devel
RUN             mkdir /install/
WORKDIR         /install/
#install perl
RUN             wget http://www.cpan.org/src/5.0/perl-5.16.3.tar.gz
RUN             tar zxvf perl-5.16.3.tar.gz
WORKDIR         /install/perl-5.16.3
RUN             ./Configure -des -Dusethreads
RUN             make && make install
RUN             cpan -fi Log::Log4perl YAML::XS Data::Dumper DBI IOC Redis Time::Piece Path::Class
RUN             cpan -fi autodie Thread::Queue threads
RUN             cpan -fi DBIx::Connector
RUN             cpan DBD::mysql

#Install the Application
RUN             mkdir /share/
WORKDIR         /share/
ADD             dist/jobs-producer-1.0.tgz /share/
RUN             mkdir -p /mnt/ad_feed
RUN             mkdir -p /mnt5/ad_feed

#Start the Application
RUN     mkdir -p /app/
ADD     start.sh /app/
WORKDIR /app
CMD    [ "./start.sh" ]

Makefile
IMAGE=sillycat/jobs-producer
TAG=1.0
NAME=jobs-producer
REPOSITORY=registry.sillycat.com

push-local:
    docker push  $(REPOSITORY)/$(IMAGE):$(TAG)

app-clean:
    rm -fr dist
    rm -fr $(NAME)-$(TAG)

app-init:
    curl -sS https://getcomposer.org/installer | php
    php composer.phar install

app-build:
    mkdir -p ./$(NAME)-$(TAG)/logs
    mkdir -p ./dist
    cp -r ./conf ./$(NAME)-$(TAG)/
    cp -r ./lib  ./$(NAME)-$(TAG)/
    cp -r ./src  ./$(NAME)-$(TAG)/
    cp -r ./vendor ./$(NAME)-$(TAG)/
    cp *.pl           ./$(NAME)-$(TAG)/
    tar -cvzf ./dist/$(NAME)-$(TAG).tgz ./$(NAME)-$(TAG)

docker-context:

build: docker-context
    sudo docker build -t $(REPOSITORY)/$(IMAGE):$(TAG) .

run-stage:
    sudo docker run -v /opt/jobs-producer/logs:/share/$(NAME)-$(TAG)/logs -v /mnt/ad_feed:/mnt/ad_feed -v /mnt5/ad_feed:/mnt5/ad_feed -d -e RUNNING_ENV=stage --name $(NAME) $(REPOSITORY)/$(IMAGE):$(TAG)

debug:
    sudo docker run -v /opt/jobs-producer/logs:/share/$(NAME)-$(TAG)/logs -v /mnt/ad_feed:/mnt/ad_feed -v /mnt5/ad_feed:/mnt5/ad_feed -ti -e RUNNING_ENV=stage --name $(NAME) $(REPOSITORY)/$(IMAGE):$(TAG) /bin/bash

clean:
    sudo docker stop ${NAME}
    sudo docker rm ${NAME}

logs:
    sudo docker logs ${NAME}

publish:
    sudo docker push ${IMAGE}

start.sh
#!/bin/sh -ex

cd /share/jobs-producer-1.0
perl JobProducerApp.pl

References:
log4perl
http://unmi.cc/perl-log4perl-user-guide/

IOC
http://collaboration.cmc.ec.gc.ca/science/rpn/biblio/ddj/Website/articles/TPJ/2005/0501/0501a/0501a.html
http://perlalchemy.blogspot.com/2011/01/dependency-injection-or-removing.html
http://www.drdobbs.com/web-development/inversion-of-control-in-perl/184416179#l1
http://search.cpan.org/~stevan/IOC-0.29/lib/IOC.pm

Configuration File
http://perltricks.com/article/29/2013/9/17/How-to-Load-YAML-Config-Files

Mysql Connection
http://search.cpan.org/~capttofu/DBD-mysql-4.033/lib/DBD/mysql.pm

upgrade version and re-install
http://sillycat.iteye.com/blog/2193773

install DBI on mac
http://stackoverflow.com/questions/19565553/problems-with-perl-dbi-dbd-on-osx-10-9-mavericks

tap::harness test suite
http://www.4byte.cn/question/1518155/tap-harness-perl-tests-tee-output.html
分享到:
评论

相关推荐

    Centos7 离线perl-CPAN rpm包

    1. **perl-CPAN-1.9800-299.el7_9.noarch.rpm**: 这个包是Perl的 Comprehensive Perl Archive Network (CPAN) 客户端,它是一个自动化的工具,用于下载、构建、测试和安装Perl模块。CPAN包含了超过20万个Perl模块,...

    perl cpan下载源码

    可使用程序进行CPAN批量下载 _inst( \%pkg ); inst('par'); my @par = ( q{PAR}, q{PAR::Packer}, ); my @xml = ( q{XML::Simple}, q{XML::SAX}, q{XML::SAX::Expat}, ); my %pkg = ( par =&gt; \@par, ...

    perl-CPAN-1.9800-297.el7.noarch.rpm

    官方离线安装包,亲测可用。使用rpm -ivh [rpm完整包名] 进行安装

    perl-CPAN-1.9800-299.el7_9.noarch.rpm

    官方离线安装包,亲测可用。使用rpm -ivh [rpm完整包名] 进行安装

    perl-CPAN-1.9800-293.el7.noarch.rpm

    离线安装包,亲测可用

    Perl学习笔记之CPAN使用介绍

    CPAN,全称为 Comprehensive Perl Archive Network,是Perl生态系统的核心组成部分,它是一个庞大的资源库,包含了数以千计的Perl模块、文档、源代码以及Perl相关的工具。CPAN不仅提供了方便的模块下载和安装方式,...

    Perl Module from CPAN

    Perl Module from CPAN, bugzilla essential perl modules 公司内部不能用FTP下载perl包,所以家里下好之后,上传到这里,公司再从这里down来安装,唉,真麻烦啊

    rh-perl530-perl-CPAN-2.27-6.el7.noarch.rpm

    官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装

    linux yum离线资源离线资源perl-5.26.1

    在离线环境中,安装额外的Perl模块可能会比较复杂,因为通常这些模块依赖于CPAN(Comprehensive Perl Archive Network)。不过,你可以将所需的模块下载到本地,然后使用`cpanm`(CPAN Minus)或手动编译来安装。...

    删除卸载单个perl模块脚本

    1. **检查已安装模块**:使用`cpan -l`或`perl -MCPAN -e 'print join("\n", map { $_-&gt;dist } CPAN::Distribution-&gt;installed)'`命令查看已安装的Perl模块列表,找到你要卸载的模块名。 2. **确定模块位置**:找到...

    perl-5.24.1.tar.gz

    Perl是一种高级的、通用的、解释型的、动态的编程语言,它的全称是 Practical Extraction and Reporting Language,即“实用提取和报告语言”。标题中的"perl-5.24.1.tar.gz"指的是Perl的一个特定版本,5.24.1,这个...

    Writing Perl Modules For CPAN

    Writing.Perl.Modules.For.CPAN Writing.Perl.Modules.For.CPAN Writing.Perl.Modules.For.CPAN Writing.Perl.Modules.For.CPAN

    perl-5.32.1.tar.gz

    Perl是一种高级的、通用的、解释型、动态的编程语言,它的全称是“ Practical Extraction and Reporting Language”,中文常被译为“实用提取和报告语言”。这个“perl-5.32.1.tar.gz”文件是Perl编程语言的源代码包...

    perl 离线安装rpm包

    1. **获取Perl RPM包**:在有网络的环境中,你可以通过`yum download`命令或访问官方或第三方RPM存储库下载Perl的RPM包。确保下载与你的CentOS版本兼容的版本。 2. **传输RPM包**:将下载的Perl RPM包通过USB驱动器...

    rh-perl526-perl-CPAN-2.18-398.el7.noarch.rpm

    官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装

    strawberry-perl-5.32.1.1-64bit perl 解释器

    4. cpan:CPAN(Comprehensive Perl Archive Network)是Perl的一个重要资源库,包含了数万种Perl模块。此目录可能指向一个本地的CPAN镜像,便于用户快速安装和更新Perl模块。 5. win32:这个目录可能包含了专门针对...

    perl-CPAN-2.18-397.el8.noarch(1).rpm

    离线安装包,亲测可用

    Modern.Perl.4th.Ed

    Learn how the language works, how to take advantage of the CPAN's immense trove of time-tested solutions, and how to write clear, concise, powerful code that runs everywhere. Specific coverage ...

    ActivePerl-5.28.1.0000-MSWin32-win10x64-65ffd8c2.rar

    它提供了一个易于安装的包,包含了Perl解释器和许多常用的Perl模块,使得开发者无需从CPAN(Comprehensive Perl Archive Network)手动下载和安装每个模块。ActivePerl还包括了编译器支持,使用户可以将Perl脚本编译...

    strawberry-perl-5.10.1.0.msi

    Strawberry Perl还包括了CPAN(Comprehensive Perl Archive Network)客户端,这是一个庞大的Perl模块仓库,开发者可以通过它轻松查找并安装各种扩展功能。这意味着在Windows环境下,Perl开发者也能享受到与Unix/...

Global site tag (gtag.js) - Google Analytics