Slide 1

Slide 1 text

1FSM؝٦ر؍ؚٝ
 ذؙصحؙ BLJZN :"1$0LJOBXB0//"40/

Slide 2

Slide 2 text

BLJZN

Slide 3

Slide 3 text

1FSMחꟼׅ׷ְ׹׿ז鑧׾ ׃תׅ

Slide 4

Slide 4 text

剑鵚ך1FSM歲꥔

Slide 5

Slide 5 text

剑鵚ֲֿ׃גְ׷הְֲ鑧׾ 耀ֹ׋ְ

Slide 6

Slide 6 text

剑鵚ךٌآُ٦ٕ׾ ס׶ִַ׷

Slide 7

Slide 7 text

VTFTUSJDU

Slide 8

Slide 8 text

VTFTUSJDU VTFXBSOJOHT VTFVUG

Slide 9

Slide 9 text

VTFW VTFXBSOJOHT VTFVUG use strict; use feature ':5.26';

Slide 10

Slide 10 text

VTFTUSJDUVSFT use strict; use warnings FATAL => 'all'; use warnings NONFATAL => qw( exec recursion internal malloc newline experimental deprecated portable ); no warnings 'once';

Slide 11

Slide 11 text

VTFTUSJDUVSFT use strict; use warnings FATAL => 'all'; use warnings NONFATAL => qw( exec recursion internal malloc newline experimental deprecated portable ); no warnings 'once'; {a => 1, 2} Odd number of elements in anonymous hash

Slide 12

Slide 12 text

ؙٓأؽٕت

Slide 13

Slide 13 text

sub new { my ($class, %args) = @_; croak("required: z") unless exists $args{z}; return bless \%args, $class; } sub z { $_[0]->{z} } CMFTT

Slide 14

Slide 14 text

Ⰻ鿇䩛דװ׷崢

Slide 15

Slide 15 text

use Moose; extends 'Point'; has 'z' => (isa => 'Int', is => 'rw', required => 1); after 'clear' => sub { my $self = shift; $self->z(0); }; .PPTF.PVTF.PP

Slide 16

Slide 16 text

堣腉搀꼽ח⢪ֲֶה׃ג 醱꧟חז׶ָ׍

Slide 17

Slide 17 text

use Class::Tiny qw(x y z); sub BUILD { my ($self, $args) = @_; croak("required: z") unless exists $args->{z}; } $MBTT5JOZ

Slide 18

Slide 18 text

㼭ׁז׮ך׾ 穈׫さ׻ׇג⢪ֲ

Slide 19

Slide 19 text

use Class::Accessor::Lite ( ro => [qw/x y z/], ); sub new { my ($class, %args) = @_; croak("required: z") unless exists $args{z}; return bless \%args, $class; } CMFTT $MBTT"DDFTTPS-JUF

Slide 20

Slide 20 text

鵚➿涸 FYQPSU遭

Slide 21

Slide 21 text

use Exporter 'import'; our @EXPORT = qw/foo bar baz/; Foo.pm test.pl use Foo; foo();

Slide 22

Slide 22 text

倜׃ְꟼ侧ך鷄⸇䖓ח !&91035ח׮鷄⸇ׅ׷ך׾ 䘌׸ָ׍

Slide 23

Slide 23 text

.PEVMF'VODUJPOT use Module::Functions qw/get_public_functions/; use Exporter 'import'; our @EXPORT = get_public_functions; use JSON qw/decode_json/; sub bar { ... } sub _foo { ... } 㢩鿇ַ׵FYQPSU׃׋ꟼ侧כ搀鋔 @ַ׵㨣ת׷ꟼ侧כ搀鋔

Slide 24

Slide 24 text

*NQPSUFS use Importer Importer => 'import'; use Importer 'List::Util' => ( any => {-as => 'list_util_any'}, ); VTF&YQPSUFSJNQPSUךַ׻׶ ⴽせדJNQPSUדֹ׷

Slide 25

Slide 25 text

ٌآُ٦ٕ ٗ٦ت٦

Slide 26

Slide 26 text

⹛涸חٌآُ٦ٕ׾铣׫鴥׬ ❌ eval qq{require "Plugin/$name.pm"}

Slide 27

Slide 27 text

6/*7&34"-SFRVJSF 'Foo::Bar'->require;דֹ׷ ַ׏ְְֿ׌ֽ*/$״׶ٗ٦س幥׫ַⴻ㹀

Slide 28

Slide 28 text

.PEVMF-PBE ؝،ٌآُ٦ٕ ءٝفٕ׌׃暴ח⢪׏ג㉏겗זְ

Slide 29

Slide 29 text

$MBTT-PBE USZ@MPBE@DMBTT ׅדחٗ٦س幥׫ַⴻ倖ׅ׷JT@DMBTT@MPBEFE

Slide 30

Slide 30 text

.PEVMF3VOUJNF $MBTT-PBE׮ⰻ鿇ד⢪׏גְ׷ ٌآُ٦ٕٗ٦ت٦ך㹀殢

Slide 31

Slide 31 text

require_module($name); use_package_optimistically($name); compose_module_name('Foo', $name); ٌآُ٦ٕⰻדؒٓ٦ָ涪欰׃׋הֹ׌ֽ⢽㢩׾䫎־׷ 湫䱸KPJO 'PP OBNF ׃זְ

Slide 32

Slide 32 text

֮׷ط٦يأل٦أ⟃♴ך ٌآُ٦ٕ׾ׅץגٗ٦سׅ׷

Slide 33

Slide 33 text

use Module::Find qw/useall/; useall('Foo::Handler'); .PEVMF'JOE 'PP)BOEMFS⟃♴ח֮׷ 'PP)BOEMFS"װ'PP)BOEMFS"#׾ٗ٦س

Slide 34

Slide 34 text

5ZQF5JOZ׾ ⢪׏ג㘗׾⢪ֲ

Slide 35

Slide 35 text

؝٦سָ竰ֺ駈ׁ׸גְ׏׋ ذأزךقٕػ

Slide 36

Slide 36 text

sub create_xxx { my (%args) = @_; if ($args{foo}) { ... } db->insert( x => 100, y => 'abc', %args, ); } ְ׹׿זךָ床ׇ׷ 剑穄涸חכ湫䱸床׃ג׃תֲ ㄎן⳿׃⩎חׅץג㨻י׷

Slide 37

Slide 37 text

UZQPח䓲ְ ⢪ְ倯ָⴓַ׵זְךד ְ׹ְ׹鋅חְֻ

Slide 38

Slide 38 text

床׏גֹ׋䒷侧׾ ثؑحؙׅ׷

Slide 39

Slide 39 text

ֿ׿זהֹחכغٔر٦ة 䗳갭ػًٓ٦ةָ床ׁ׸גְ׷ַ 㘗ثؑحؙ

Slide 40

Slide 40 text

use Params::Validate qw(:all); sub foo { my %args = validate(@_, { foo => { type => ARRAYREF }, bar => { isa => 'Bar' }, }); } 1BSBNT7BMJEBUF

Slide 41

Slide 41 text

use Data::Validator; sub foo { state $rule = Data::Validator->new( foo => { isa => 'ArrayRef' }, bar => { isa => 'Bar' }, ); my $args = $rule->validate(@_); } %BUB7BMJEBUPS .PVTFך㘗 غٔر٦ةך㹀纏ךٍؗحءָُ〳腉 「ֽ《׏׋ػًٓ٦ةכIBTISFGד乼⡲

Slide 42

Slide 42 text

use Smart::Args; sub foo { args my $foo => 'ArrayRef', my $bar => 'Bar', ; } 4NBSU"SHT !@׾床ׅ䗳銲ָזְ غٔر٦ةך㹀纏׾ٍؗحءُדֹזְ 「ֽ《׏׋ػًٓ٦ةכ㢌侧ד乼⡲

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

!@׾床ׁ׆חㄎן⳿׃⯋ך!@׾《׸׷ 1BE8BMLFS׾⢪ְծ床׃׋㢌侧せ׾《׶⳿ׅ

Slide 45

Slide 45 text

use Mouse::Util::TypeConstraints; my $type = find_or_create_isa_type_constraint('Int'); $type->check($x); ⰻ鿇דכ.PVTFך㘗׾䪔ֲ

Slide 46

Slide 46 text

5ZQF5JOZ

Slide 47

Slide 47 text

Any Item Bool Maybe[`a] Undef Defined Value Str Num Int ClassName RoleName Ref ScalarRef ArrayRef[`a] HashRef[`a] CodeRef RegexpRef GlobRef FileHandle Object ArrayRef[User] Maybe[Str] .PPTF✼䳔

Slide 48

Slide 48 text

Map[`k, `v] Tuple[...] Dict[...] Optional[`a] InstanceOf[`a] ConsumerOf[`a] HasMethods[`a] Overload[`a] Tied[`a] StrMatch[`a] Enum[`a] OptList LaxNum StrictNum CycleTuple[`a] MkOpt Split[`a] Join[`a] Dict[a => Int, b => Str] Enum['public', 'private'] .PPTF95ZQFT4USVDUVSFE✼䳔

Slide 49

Slide 49 text

.PVTFה5ZQF5JOZך麩ְ

Slide 50

Slide 50 text

use Mouse::Util::TypeConstraints; subtype 'NonEmptyStr', as 'Str', where { length($_) > 0 }; my $type = find_type_constraint('NonEmptyStr'); $type->check('str'); .PVTF ؚٗ٦غٕז㘗׾㹑鎉

Slide 51

Slide 51 text

use Type::Standard -types; use Type::Utils -all; subtype 'NonEmptyStr', as Str, where { length($_) > 0 }; NonEmptyStr->check('str'); 5ZQF5JOZ ׉ך㜥ד㘗ךؔـآؙؑز׾⡲䧭 㢩鿇ַ׵⢪ֲ㜥さכFYQPSUׇׁ׷

Slide 52

Slide 52 text

4NBSU"SHT5ZQF5JOZ 4NBSU"SHTד5ZQF5JOZך㘗׾ 䪔ִ׷״ֲח׃׋׮ך 4NBSU"SHTה㢌׻׵׆⢪ִ׷

Slide 53

Slide 53 text

use Types::Standard -types; sub foo { args my $x => {isa => 'Int', default => 100}, my $y => {isa => Str, default => 'abc'}, my $bar => 'Bar', my $bar => 'NonEmptyStr', ; } 5ZQF5JOZך㘗׮⢪ִ׷ 俑㶵⴨ה׃ג׮床ׇ׷ .PVTF6UJM5ZQF$POTUSBJOUTד㹑鎉׃׋㘗׮⢪ִ׷

Slide 54

Slide 54 text

use Types::Standard qw/Str/; use Params::ValidationCompiler; sub foo { state $validator = validation_for( params => { foo => { type => Str }, }, ); my %args = $validator->(@_); } 1BSBNT7BMJEBUJPO$PNQJMFS

Slide 55

Slide 55 text

倜׃ְ1FSMך 堣腉׾⢪ֲ

Slide 56

Slide 56 text

QPTUYEFSFGFSFODF QFSM⟃꣬ד姻䒭堣腉⻉

Slide 57

Slide 57 text

$$a $a->$* @$a $a->@* $#$a $a->$#* %$a $a->%* &$a $a->&* *$a $a->**

Slide 58

Slide 58 text

$$a $a->$* @$a $a->@* $#$a $a->$#* %$a $a->%* &$a $a->&* *$a $a->**

Slide 59

Slide 59 text

my $x = {a => [1, 2, 3], b => [4]}; 兛鸐ךEFSFGFSFODF @{$x->{a}} $x->{a}->@* QPTUYEFSFGFSFODF

Slide 60

Slide 60 text

map { $_->id } @{ Foo->bar( ... ) }; map { $_->id } Foo->bar( ... )->@*; 兛鸐ךEFSFGFSFODF QPTUYEFSFGFSFODF

Slide 61

Slide 61 text

use constant A => [1, 2, 3]; !"דכזְ׋׭" ד ㄎן⳿׃גֶֻ䗳銲ָ֮׷ 兛鸐ךEFSFGFSFODF @{A()} A->@* QPTUYEFSFGFSFODF @{+A}

Slide 62

Slide 62 text

QFSM ׉׸⟃⵸ד׮⢪ְ׋ְ

Slide 63

Slide 63 text

QPTUYEFSFGFSFODF׾㢌䳔 IUUQTHJUIVCDPNBLJZNMFHBDZ@QPTUYEFSFG

Slide 64

Slide 64 text

11*׾⢪׏ג WBS!׾!WBSח 剅ֹ䳔ִ׷

Slide 65

Slide 65 text

➙ּׅQPTUYEFSFGFSFODF ⢪ִ׷

Slide 66

Slide 66 text

ֶ׻׶

Slide 67

Slide 67 text

5.5085%* 5IFSFT.PSF5IBO0OF8BZ5P%P*U