Author: Mons Anderson (MONS)
search.cpan.org/~mons XML-Declare uni-perl AnyEvent-SMTP accessors-fast ex-lib Test-If AnyEvent-RPC Acme-CPANAuthors-AnyEv...
github.com/Mons AnyEvent::HTTP::Server AnyEvent::UA AnyEvent-XMPP-2 Proc::Vsize Daemond Devel::Rewrite CatalystX-InternalR...
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 ...
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 ...
use uni::perl ':dumper'; use strict; use feature qw(say state switch); no warnings; use warnings qw(FATAL ...); no warning...
Secret feature ;) (pluggable) use uni::perl ':ru'; say cp1251::encode «...»; say cp1251::decode «...»; say koi8r::encode «...
XML::* XML::RPC::Fast XML::Parser::Style::EasyTree XML::Hash::LX XML::Fast XML::Declare
Test::* Test::Dist kwalitee for cpants.perl.org
Test::* Test::If — tired of eval { use Test::...; 1 } or plan skip_all => «...»; $Test::...::VERSION >= 1.23 or plan skip_...
Test::* Test::More::UTF8 against Wide 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(); __PACK...
accessors::fast use accessors::fast qw(field1 field2); vs use base 'Class::Accessors::Fast'; __PACKAGE__->mk_accessors( qw...
constant::def use constant::abs 'My::DEBUG' => 1; use constant::def DEBUG => 0; vs BEGIN { *My::DEBUG = sub () { 1 }; } BE...
AnyEvent::* AnyEvent::Connection manage your connection AnyEvent::SMTP send 7k emails/s AnyEvent::Memcached client with rg...
Image::* Image::JpegTran (binding to jpegtran) Image::LibExif 4000% (40 times) faster than Image::ExifTool
Daemond (github) - Correct daemonization - Detach - redirection of output - keeping the fileno for STD* handles - chroot -...
Simple Daemond  package SampleD; use Daemond -parent; name 'test'; cli;  # Command line control proc;  # Alter $0 children...
Daemond CLI Usage: [options] [start|stop|restart|check] Options: -v, --verbose increase verbosity level -f, --nodetach run...
Devel::Rewrite # @rewrite s/^#s+//; # use Some::Development::Module; # @rewrite s/some_call/another_call/; $object->some_c...
Dash-Leak use Dash::Leak; { leaksz "block label"; # some code, that may leak } leaksz "tests begin"; s...
Upcoming SlideShare
Loading in...5
×

Владимир Перепелица "Модули"

1,019

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,019
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Владимир Перепелица "Модули"

  1. 1. Author: Mons Anderson (MONS)
  2. 2. 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
  3. 3. github.com/Mons AnyEvent::HTTP::Server AnyEvent::UA AnyEvent-XMPP-2 Proc::Vsize Daemond Devel::Rewrite CatalystX-InternalRedirect
  4. 4. use lib ? use lib '../lib'; use lib '/opt/project/lib'; use FindBin; use lib «$FindBin::Bin/../lib»;
  5. 5. 09.11.2008 ex::lib (now lib::abs) (thanks to A. Shrub ;)
  6. 6. use lib::abs (ex::lib) use lib::abs '../lib'; use lib::abs '../../*/lib';
  7. 7. 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);
  8. 8. use warnings? Use of uninitialized value...
  9. 9. 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
  10. 10. 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';
  11. 11. 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 «...»;
  12. 12. XML::* XML::RPC::Fast XML::Parser::Style::EasyTree XML::Hash::LX XML::Fast XML::Declare
  13. 13. Test::* Test::Dist kwalitee for cpants.perl.org
  14. 14. Test::* Test::If — tired of eval { use Test::...; 1 } or plan skip_all => «...»; $Test::...::VERSION >= 1.23 or plan skip_all => «...»;
  15. 15. Test::* Test::More::UTF8 against Wide character in print at Test/Builder.pm line 1698.
  16. 16. Fun syntax - lvalue - self::init - accessors-fast - constant-def
  17. 17. lvalue sub mysub : lvalue { get { return 'result for get'; } set { my $set_value = shift; # ... } }
  18. 18. 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));
  19. 19. accessors::fast use accessors::fast qw(field1 field2); vs use base 'Class::Accessors::Fast'; __PACKAGE__->mk_accessors( qw(field1 field2) );
  20. 20. constant::def use constant::abs 'My::DEBUG' => 1; use constant::def DEBUG => 0; vs BEGIN { *My::DEBUG = sub () { 1 }; } BEGIN { defined &DEBUG or *DEBUG = sub () { 0 }; }
  21. 21. AnyEvent::* AnyEvent::Connection manage your connection AnyEvent::SMTP send 7k emails/s AnyEvent::Memcached client with rget (for memcachedb) AnyEvent::Worker any blocking work for AE app AnyEvent::Handle::Writer use sendfile() with write queue AnyEvent::HTTP::Server pipeline, websockets, http/1.1 AnyEvent::UA http/1.1 useragent
  22. 22. Image::* Image::JpegTran (binding to jpegtran) Image::LibExif 4000% (40 times) faster than Image::ExifTool
  23. 23. 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
  24. 24. Simple Daemond package SampleD; use Daemond -parent; name 'test'; cli; # Command line control proc; # Alter $0 children 1; # How many children pid '/var/run/test.pid'; child { $SIG{USR2} = sub { exit; }; while() { do_job(); } };
  25. 25. Daemond CLI Usage: [options] [start|stop|restart|check] Options: -v, --verbose increase verbosity level -f, --nodetach run in nodetach mode -c N, --children N redefine count of children
  26. 26. 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 …
  27. 27. 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 ...
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×