A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.

Jump to

Quick reference

Showing posts with label cpan. Show all posts
Showing posts with label cpan. Show all posts

Pinto commands, working with pinto and cpm

# Check what's in Pinto CPAN mirror:

pinto list --root $PINTO_MIRROR | grep Your::Module | head -1

# ...or do the same locally (note the space after the module name)

grep 'Smurf::Foo ' ~/.perl-cpm/sources/$DARKPAN/02packages.details.txt

# Downgrade a module using cpm

cpm install --reinstall --no-prebuilt --resolver metadb --resolver 02packages,$DARKPAN_NAME $DARKPAN_FQDN_WITH_BASIC_AUTH/authors/id/U/UB/UBUNTU/Smurf-Foo-1.23.tar.gz


Improving Perl's Test2 documentation and using the metacpan docker image

#fixallthethings #tooling #fail on Mac OSX 13.6 High Sierra

Test that all your module dependencies are listed in the cpanfile

Put this at xt/author/cpanfile.t: Thanks Anton & the team.

Use cpm to manage your Perl dependencies

cpm is much faster than cpanm because it makes HTTP requests in parallel and caches modules between runs. The output is also infinitely more clear than cpanm.

# Define the local lib directory
unset PERL5LIB; unset PERL_LOCAL_LIB_ROOT; eval $(perl -Mlocal::lib=./local)

# Install cpm using cpanm
cpanm -nf -L local App::cpm # 35 modules

# Then manually install any problematic modules (as necessary) that have been moved in/out of core
cpm install Module::Build
cpm install Module::Pluggable
cpm install Archive::Extract
cpm install CGI::Cookie
cpm install CGI

# Finally fetch all the CPAN and other dependencies
export DARKPAN=https://username:passwork@mydarkpan.example.com
cpm install --resolver 02packages,$DARKPAN --resolver metadb

Note: --resolver is experimental. The standard argument is --mirror

Thanks HypnoMark

# Another form
cpm install --show-build-log-on-failure --resolver metadb --resolver 02packages,$PINTO_MIRROR --feature=client

# s/PINTO_MIRROR/DARKPAN/

How to use local::lib to install Perl modules locally

First:

cd project_dir
eval $( perl -Mlocal::lib=local )

Install dependencies:

cpanm -L local --installdeps .

Or individual modules:

cpanm -L local Some::Module

PHP, pecl, phpize PDO, mysqli for Perl devs

"pecl" is the same as "cpan"
"phpize" is the equivalent of "perl Makefile.pl"
"PDO" is PHP's DBI equivalent (i.e. general purpose RDBMS connector)
"mysqli" is the more modern version of the mysql-specific connector

How to install CPAN Perl modules on Ubuntu using apt-get package manager

script:

PACKAGE=$(echo "$1" | perl -e '$x=<>; chomp($x); $x=~s/::/-/g; $x=lc($x); print "lib$x-perl"')
sudo apt-get install $PACKAGE

Thanks

CPAN config

o conf prerequisites_policy 'follow'
o conf make_install_make_command 'sudo make'
o conf build_requires_install_policy yes
o conf commit

Date/Time perl modules

  • Date::Manip - Big. Needs several step sto convert to/from eopch seconds. But you could just subtract 1 week's worth of seconds.
  • Date::Calc - Less big, simpler. Has Add_Delta_Days. Doesn't generate BST from epoch seconds (on Mac).
  • POSIX - has strftime. Can easily generate epoch seconds from the current time. Lacking in conversion to date?
  • DateTime - The best and easiest.

XML::Validator::Schema

#!/usr/bin/perl

use XML::SAX::ParserFactory;
use XML::Validator::Schema;
# create a new validator object, using foo.xsd
$validator = XML::Validator::Schema->new(file => 'foo.xsd');
# create a SAX parser and assign the validator as a Handler
$parser = XML::SAX::ParserFactory->parser(Handler => $validator);
# validate foo.xml against foo.xsd
eval { $parser->parse_uri('foo.xml') };
die "File failed validation: $@" if $@;

The problem is:

How to use Catalyst to automatically create Perl DBIx::Class modules

UNTESTED:

1. install Catalyst

2. pretend like you're going to create a catalyst app

catalyst.pl MyFakeApp

3.

cd MyFakeApp
./script/myfakeapp_create.pl model MyModelName DBIC::Schema \
MyApp::SchemaClass create=static dbi:mysql:... user password


http://search.cpan.org/~rkitover/Catalyst-Model-DBIC-Schema-0.29/lib/Catalys
t/Helper/Model/DBIC/Schema.pm



one I did earlier

perl ./script/tagindexer_create.pl model RequestDB DBIC::Schema
TagIndexer::Schema create=static
'dbi:mysql:database=request;host=[ip address];port=3306' tagindexer
tagindexer