Владимир Перепелица "Модули"
TRANSCRIPT
Author: Mons Anderson (MONS)
search.cpan.org/~mons
XML-Declare
uni-perl
AnyEvent-SMTP
accessors-fast
ex-lib
Test-If
AnyEvent-RPC
Acme-CPANAuthors-AnyEvent
constant-def
AnyEvent-Worker
Image-JpegTran
XML-Hash-LX
Socket-AcceptFilter
XML-Parser-Style-EasyTree
lvalue
Catalyst-Action-Serialize-XML-Hash-LX
XML-Fast
Devel-Leak-Cb
lib-abs
Crypt-RSA-Yandex
AnyEvent-Connection
AnyEvent-Memcached
Test-More-UTF8
Dash-Leak
AnyEvent-Handle-Writer
Variable-Eject
self-init
XML-RPC-Fast
Image-LibExif
Test-Dist
github.com/Mons
AnyEvent::HTTP::Server
AnyEvent::UA
AnyEvent-XMPP-2
Proc::Vsize
Daemond
Devel::Rewrite
CatalystX-InternalRedirect
use lib ?
use lib '../lib';
use lib '/opt/project/lib';
use FindBin;
use lib $FindBin::Bin/../lib;
09.11.2008
ex::lib(now lib::abs)
(thanks to A. Shrub ;)
use lib::abs (ex::lib)
use lib::abs '../lib';
use lib::abs '../../*/lib';
use, use, use?
use utf8;use strict;use warnings;use Carp;use Data::Dumper;use open qw(:utf8 :std);use mro 'c3';use feature qw(say state switch);
use warnings?
Use of uninitialized value...
common::sense?
- No utf8 until v3.0
- No open :utf8 support for v3.0+
- No require perl 5.10+ for features
- No Carp
- No mro
use uni::perl ':dumper';
use strict;use feature qw(say state switch);no warnings;use warnings qw(FATAL ...);no warnings qw(exec newline);use utf8;use open (:utf8 :std);use mro 'c3';use autouse 'Carp';use autouse 'Data::Dumper';
Secret feature ;) (pluggable)
use uni::perl ':ru';
say cp1251::encode ...;say cp1251::decode ...;
say koi8r::encode ...;say koi8r::decode ...;
say cp866::encode ...;say cp866::decode ...;
XML::*
XML::RPC::FastXML::Parser::Style::EasyTree
XML::Hash::LX
XML::Fast
XML::Declare
Test::*
Test::Distkwalitee forcpants.perl.org
Test::*
Test::If tired of
eval { use Test::...; 1 }or plan skip_all => ...;$Test::...::VERSION >= 1.23or plan skip_all => ...;
Test::*
Test::More::UTF8
againstWide character in print at Test/Builder.pm line 1698.
Fun syntax
- lvalue- self::init- accessors-fast- constant-def
lvalue
sub mysub : lvalue {get {return 'result for get';}set {my $set_value = shift; # ...}}
self::init
use self::init\-a => qw(a b),\-b => (),\-c => qw( c c ),;
vs
__PACKAGE__->a(qw(a b));__PACKAGE__->b();__PACKAGE__->c(qw(c c));
accessors::fast
use accessors::fast
qw(field1 field2);
vs
use base 'Class::Accessors::Fast';__PACKAGE__->mk_accessors(qw(field1 field2));
constant::def
use constant::abs 'My::DEBUG' => 1;use constant::defDEBUG => 0;
vs
BEGIN { *My::DEBUG = sub () { 1 }; }BEGIN {defined &DEBUG or*DEBUG = sub () { 0 };}
AnyEvent::*
AnyEvent::Connectionmanage your connectionAnyEvent::SMTPsend 7k
emails/sAnyEvent::Memcachedclient with rget (for
memcachedb)AnyEvent::Workerany blocking work for AE
appAnyEvent::Handle::Writeruse sendfile() with write queue
AnyEvent::HTTP::Serverpipeline, websockets,
http/1.1AnyEvent::UAhttp/1.1 useragent
Image::*
Image::JpegTran(binding to jpegtran)
Image::LibExif4000% (40 times) fasterthan Image::ExifTool
Daemond (github)
- Correct daemonization-Detach- redirection of output- keeping the fileno for STD* handles- chroot- change user- Pluggable engine- Built-in CLI (Command-line interface)- Pidfile- Scoreboard- Different packages for child and parent- Child monitoring for parent death- Timers for termination
Simple Daemond
package SampleD;
use Daemond -parent;name 'test';cli; # Command line controlproc; # Alter $0children 1; # How many childrenpid '/var/run/test.pid';
child {$SIG{USR2} = sub { exit; };while() {do_job();}};
Daemond CLI
Usage: [options] [start|stop|restart|check]Options:-v, --verboseincrease verbosity level-f, --nodetachrun in nodetach mode-c N, --children Nredefine count of children
Devel::Rewrite
# @rewrite s/^#\s+//;# use Some::Development::Module;
# @rewrite s/some_call/another_call/;$object->some_call;
sub something {# @include sub.debug.inc...}
perl -MDevel::Rewrite
Dash-Leak
use Dash::Leak;{leaksz "block label";# some code, that may leak}
leaksz "tests begin";some_operation($arg);leaksz "some_operation", sub {warn sprintf"We leaked by %+d kilobytes;", shift};
$ DEBUG_MEM=1 perl ...