Владимир Перепелица "Модули"
Upcoming SlideShare
Loading in...5
×
 

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

on

  • 1,159 views

 

Statistics

Views

Total Views
1,159
Views on SlideShare
1,054
Embed Views
105

Actions

Likes
0
Downloads
0
Comments
0

3 Embeds 105

http://webcrunch.ru 95
http://developers.rambler.ru 9
http://www.webcrunch.ru 1

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

CC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Владимир Перепелица "Модули" Владимир Перепелица "Модули" Presentation 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 View slide
  • use lib ? use lib '../lib'; use lib '/opt/project/lib'; use FindBin; use lib «$FindBin::Bin/../lib»; View slide
  • 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::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_all => «...»;
  • 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(); __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::def DEBUG => 0; vs BEGIN { *My::DEBUG = sub () { 1 }; } BEGIN { defined &DEBUG or *DEBUG = sub () { 0 }; }
  • 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
  • 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 - 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 control proc; # Alter $0 children 1; # How many children pid '/var/run/test.pid'; child { $SIG{USR2} = sub { exit; }; while() { do_job(); } };
  • 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
  • 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 ...