Slide 1

Slide 1 text

)BUFOB3FNPUF*OUFSOTIJQ &9铺紶 1FSMه٭ع؞ٔ٤و JEUL[XULT悂很㼵

Slide 2

Slide 2 text

舅䄕磆☭ ˝ JEUL[XULT悂很㼵 ˝ 䇗僖⪌炘 ˝ 哅ⳉ塷 ˝ ؜ؠّٙ ˝ (JHB7JFXFS ˝ עיםرؕؓٛ٭磙▼ ˝ 뇧嫎סJ׼؆ל

Slide 3

Slide 3 text

1FSM鐆؆ד׆כ傴ַג׆כֵ׽ױ ׌־

Slide 4

Slide 4 text

1FSM

Slide 5

Slide 5 text

1FSM 1FSMق٭ٜכעյٚٛ٭٬ؚؗ٭ٜמ׻זיꝧ氦׈׿גوٞ ءِٚ٤ء銧鏤ךֵ׾ն㲔榫䓪כ㛡喋䓪؅ꄆ釱׊יֽ׽յ$銧鏤 ׷TFEյBXLյبؘٜتؠٛوعםל☽סوٞءِٚ٤ء銧鏤ס⨣ ׿ג嚀耆؅⹦׽⪌׿יַ׾նؘؗه٬ؓوٛآ٭ب٘٤յبتط ّ畘杼յط؞تع⭚杼םלסوٞءّٚ؅傴ׂסמ䇶ׂ榫ַ׼׿ יַ׾ն

Slide 6

Slide 6 text

1FSM ˝ (Pכ鷿זיյؤ٤قٜؕ؅׊םַؕ٤ذوٛذ㑔銧鏤 ˝ #FUUFSTIFMMכ׊י׵✳ֻ׾׊յؘؗهؓوٛآ٭ب٘٤؅ 傴ׂ׆כדזיך׀׾ ˝ 碛企ַؘؗهꝧ氦ס鷹⪮כ׊יյ⹿ׂ־׼☔妳ס-JHIUXFJHIU -BOHVBHF ˝ עים%F/"NJYJ-*/& ˝ ײם׈؆ֿ鿥㷯׈׿׾◀㲊סز٭ّך׵

Slide 7

Slide 7 text

إ٭ٜ 侇ꝴ䍚ךր1FSM㱭⪒מ杼鉮׊גցמם׾

Slide 8

Slide 8 text

إ٭ٜ סע׵ה؀؆ꦘ׊ַסך ˝ 仴㰆סؤ٭غ؅鐆׳ג״ס⹦ז䫇־׽ֿ⛼׿׾׻ֹמם׾ ˝ ㍭זגכ׀סؕ٤ظشؠتכ׊י ˝ ⼽׽סؤ٭غ؅⹆縒מ׊םֿ׼1FSMֿ傴ׄ׾׻ֹמם׾

Slide 9

Slide 9 text

1FSMמ鉴׿יַׂ⯥מ

Slide 10

Slide 10 text

غ؞ْٖ٤عעQFSMEPDך䌕ׂ % perldoc Carton # Ϟδϡʔϧʢޙड़ʣͷυΩϡϝϯτ % perldoc -f print # ૊ΈࠐΈؔ਺͸ -f % perldoc -v !" # ૊ΈࠐΈม਺͸ -v % perldoc perl

Slide 11

Slide 11 text

$1"/ ˝ 5IF$PNQSFIFOTJWF1FSM"SDIJWF/FUXPSL ˝ IUUQTNFUBDQBOPSH ˝ ┩槡╈ס׈ױ׉ױם1FSMٓةٖ٭ֿٜ꥗ױזיַ׾ ˝ 1FSMס銧鏤氳ם䍚ײס┉חؤِٖؼطؔ

Slide 12

Slide 12 text

$BSUPO ˝ 3VCZךַֹ#VOEMFSײגַם׵ס ˝ cpanfileמ傴ַגٓةٖ٭ٜ⺲!ف٭ة٘٤؅յٞ٭؜ٜס ظؔٝؠعٛlocal/מؕ٤تع٭ٜ׊יׂ׿׾ ˝ ز٭ّךע%PDLFS✳ֹסךֵױ׽ゖ갭מעם׼םַ־׵

Slide 13

Slide 13 text

1FSMכַֹ銧鏤

Slide 14

Slide 14 text

˝ ٓةٖ٭ٜ package Example!"Greeter; use strict; use warnings; sub greet { my ($class, $what) = !#; print "hello, $what\n"; } 1;

Slide 15

Slide 15 text

˝ ْؕ٤تؠٛوع use strict; use warnings; use lib 'lib'; use Example!"Greeter; Example!"Greeter!#greet('world'); ˝ 㲔车 % perl -Ilib main.pl hello, world

Slide 16

Slide 16 text

ֽױ׋םַ ˝ VTFTUSJDUVTFXBSOJOHT ˝ 碛ס1FSMע־ם׽舅榺 ˝ VTFTUSJDU׌׾כNZך㲚銧׊יַםַ㚺丗ֵֿ׾כꪐ氳מ ؙٚ٭ ˝ VTFXBSOJOHT׌׾כ閛⼔ֿ僗Ⲗמם׾ ˝ 鎋׊ׂעQFSMEPDTUSJDUQFSMEPDXBSOJOHT

Slide 17

Slide 17 text

㚺丗 ˝ 1FSMס㚺丗עյאסظ٭ذ㑔מ䑴׋יبةٜכ⽛ף׿׾鋗⺘ֿ ⩝꯽מחׂ ˝ my $hogeס׻ֹמ׊י㚺丗㲚銧׌׾ ˝ ꪐ氳ם㑔עםַ ˝ $@%

Slide 18

Slide 18 text

ت؜ٚ ˝ חס⡁ ˝ 丗㰄׵乃㰄⮛׵׌׬יت؜ٚ my $scalar1 = 'test'; my $scalar2 = 1000; my $scalar3 = \@array; # ϦϑΝϨϯεʢޙड़ʣ ˝ ׷狜乃㰄⮛עGBMTZם⡁כ׊י䣽؂׿׾ ˝ ׵GBMTZ

Slide 19

Slide 19 text

VOEFG ˝ ت؜ٚ㚺丗ס⮣僿⡁ ˝ ַ؂׹׾VOEFOFEכ־OJMכ־ ˝ EFOFE磝ײ鱮ײ㚺丗ךVOEFG־לֹ־زؘشؠך׀׾ my $x; print $x; # "Use of uninitialized value $x in print"

Slide 20

Slide 20 text

!鿥⮛ my @array = ('a', 'b', 'c');

Slide 21

Slide 21 text

鿥⮛׫סؓؠجت print $array[1]; # !" b ˝ 鿥⮛סַה釐碛עت؜ٚםסךյؓؠجت׌׾㕙⺬עBSSBZ<> מם׾ ˝ BSSBZכ!BSSBZע⮯擻

Slide 22

Slide 22 text

鿥⮛ס䳩⛼ $array[0]; # get $array[1] = 'hoge'; # set push @array, 'meow'; # ࠷ޙʹཁૉΛ௥Ճ my $v = shift @array; # ࠷ॳͷཁૉΛऔΓআ͍ͯฦ͢ my $length = scalar @array; # ௕͞ for my $e (@array) { # શཁૉϧʔϓ print $e; }

Slide 23

Slide 23 text

鿥⮛ס䳩⛼ my @doubles = map { $_ * 2 } @numbers; # ͢΂ͯΛ2ഒʹͨ͠഑ྻΛ࡞Δ my @over20 = grep { $_ > 20 } @numbers; # 20ΑΓେ͖ͳ਺͚ͩΛूΊͨ഑ྻΛ࡞Δ ˝ $_ע攐墤㚺丗 ˝ ׆ס㕙⺬ךע鿥⮛ס⺨釐碛ֿꯂמ⹦׽⭳׈׿י⪌זיׂ׾

Slide 24

Slide 24 text

ـشبٖ ˝ ַ؂׹׾ظؔؠب٘ػٛ׷ُشو my %hash = ( perl !" 'larry', ruby !" 'matz', ); ˝ עGBUDPNNBכ⽛ף׿յ QFSMMBSSZ ע QFSM MBSSZ כ⺱┉ ˝ ⺓鱨ע鿥⮛סכ׀כ⺱喋םٛتعדֿյל؆ם㚺丗מ劲硯׌׾ ־ךؓؠجتס☼亠ֿ㚺؂׾ ˝ ؤ٤ط؞تع

Slide 25

Slide 25 text

ٛنؒٝ٤ت ˝ כי׵ꄆ釐 ˝ ٛنؒٝ٤تت؜ٚ鿥⮛ـشبٖםל׫ס⹆拨 ˝ 1FSMס鿥⮛׷ـشبٖע־ם׽碛儢 ˝ 邾ꥭםظ٭ذ啶鵰؅⛼׾㕙⺬מ䑒׍䑒釐מם׾

Slide 26

Slide 26 text

ٛنؒٝ٤ت ˝ ⪌׿㯸ס车⮛؅⛼זיײ׾־ my @matrix = ( (0, 1, 2, 3), (4, 5, 6, 7), ); ˝ ׆סؤ٭غע鿥⮛ס⺬䡗מם׾ ˝ ٛتع؅⪌׿㯸מך׀םַ my @matrix = (0, 1, 2, 3, 4, 5, 6, 7);

Slide 27

Slide 27 text

א׆ךٛنؒٝ٤ت my @array = ('a', 'b', 'c'); my $ref = \@array; # @array ΁ͷϦϑΝϨϯε my $ref = ['a', 'b', 'c']; # ্هͷུهɻͪͳΈʹ \('a', 'b', 'c') ͸ผ෺ # 2ͭͷ഑ྻ΁ͷϦϑΝϨϯεΛ΋ͬͨʢ௕͞2ͷʣ഑ྻ my @matrix = ( [0, 1, 2, 3], [4, 5, 6, 7], );

Slide 28

Slide 28 text

鿥⮛ٛنؒٝ٤ت׫סؓؠجت my @array2 = @$ref; # ಄ʹ @ Λ͚ͭͯ഑ྻʹ໭͢ʢσϦϑΝϨϯεʣ print $ref!"[1]; # !" Λ࢖ͬͯ௚઀ΞΫηε

Slide 29

Slide 29 text

ـشبٖٛنؒٝ٤ت my %hash = ( perl !" 'larry', ruby !" 'matz', ); my $ref = \%hash; # ུه my $ref = { perl !" 'larry', ruby !" 'matz', };

Slide 30

Slide 30 text

ـشبٖٛنؒٝ٤ت׫סؓؠجت my $ref = { perl !" 'larry', ruby !" 'matz', }; # % Λ಄ʹ͚ͭͯσϦϑΝϨϯε # keys͸૊ΈࠐΈؔ਺ɻϋογϡͷΩʔͷҰཡΛऔಘ͢Δ my @keys = keys %$ref; print $ref!#{perl}; # !# Ͱ௚઀ΞΫηε

Slide 31

Slide 31 text

ظٛنؒٝ٤تַ؀ַ؀ ˝ םמ־ס䌋؅ظٛنؒٝ٤ت׌׾כ׀ע!\^כ־\^ך ㍱׳ my $a_of_a = [ [1, 2, 3], [4, 5, 6], ]; my @array = @{ $a!"[1] };

Slide 32

Slide 32 text

˝ 1PTUYEFSFGFSFODF my @array = $a!"[1]!"@*;

Slide 33

Slide 33 text

塜釨辐杯 ˝ 1FSMס䍚ײסץכחն״ה׶䍚ⱱ ˝ ך塜釨辐杯ٛطٜٚ؅榟䡗յ_ך乃㰄⮛מُشز׈׎׾ my ($id) = ("͜Μʹͪ͸ɺid:motemen Ͱ͢" =~ /id:(.+)/); # จࣈྻϚονͰҰ෦Λൈ͖ग़͢ my @lines = split /\n/, $text; # ೖྗΛߦʹ෼ׂ ˝ QFSMEPDQFSMSF

Slide 34

Slide 34 text

אס׮־ ˝ if乃כ־ע䘶⥼鵟׽ס׵סֿדַגֵַ׾ ˝ else ifעםׂיelsif ˝ ٜ٭وס⯆䐒啶乃 ˝ continueעnext breakעlast ˝ 乃㰄⮛ס奂鬳ע!"םלךעםׂeq ˝ QFSMEPDQFSMPQ

Slide 35

Slide 35 text

אס׮־ ˝ 乃㰄⮛ס磵⺬ע غشع璡 $hoge = 'abc' . 'def' # abcdef ˝ qw(foo bar baz)ע('foo', 'bar', 'baz')ס矴辉啶乃 ˝ perldoc -f qw

Slide 36

Slide 36 text

ؤ٤ط؞تع ˝ 1FSMסꦘ׊ַכ׆؀סץכח ˝ 䌋؅鍐❫׌׾꤀מ縒䜡׌׾䑒釐ֵֿ׾ ˝ ت؜ٚؤ٤ط؞تعכٛتعؤ٤ط؞تعֵֿ׾ my @array = (10, 20, 30); my @x = @array; # ͜ͷ @array ͸ϦετίϯςΩετͰධՁ͞ΕΔ my $y = @array; # ͜ͷ @array ͸εΧϥίϯςΩετͰධՁ͞ΕΔ my ($z) = @array; # ͜ͷ @array ͸ϦετίϯςΩετͰධՁ͞ΕΔ

Slide 37

Slide 37 text

ؤ٤ط؞تع ˝ @xֿ(10, 20, 30)מם׾סעױֵ舅抅 ˝ ךע$yע ˝ $y !" 3 ˝ 鿥⮛؅ت؜ٚؤ٤ط؞تعך鍐❫׌׾כאסꝎ׈؅鲭׌ ˝ $zמע鿥⮛ס⩝꯽釐碛ֿ♏⪌׈׿$z !" 10鿥⮛ס墦׽ ע䩰י׼׿׾

Slide 38

Slide 38 text

ؤ٤ط؞تعס׻ֵׂ׾粸 ם؆־ٗ٭ا־׼鴜׼׿ג⪌ⱱ؅⹨ׄכ׽յٛتعؤ٤ط؞تع ךע鿥⮛؅鲭׌꞊丗param()ֵֿזגכ׊י my $in = { name !" param('key') # ͜ͷؔ਺ݺͼग़͠͸ϦετίϯςΩετͰධՁ͞ΕΔ };

Slide 39

Slide 39 text

ؤ٤ط؞تعס׻ֵׂ׾粸 my $in = { name !" ('foo', 'bar', 'baz') }; my $in = { name !" 'foo', bar !" 'baz', }; כַֹ䚉׋מם׽յם׏־CBSכַֹ┘䓙閱ם؞٭ֿ榟ֻյ┘⺎鉮 םفءס⸉㍔כם׽ֹ׾

Slide 40

Slide 40 text

ؤ٤ط؞تعؠؕث sort <͜͜>; length <͜͜>; if (<͜͜>) { } for my $i (<͜͜>) { } $obj!"method(<͜͜>); my $x = <͜͜>; my ($x) = <͜͜>; my @y = <͜͜>; my %hash = ( key0 !# 'hoge', key1 !# <͜͜>, ); scalar(<͜͜>); <͜͜>;

Slide 41

Slide 41 text

ؤ٤ط؞تعؠؕث鉮璻 sort <Ϧετ>; length <Ϧετ>; if (<εΧϥ>) { } for my $i (<Ϧετ>) { } $obj!"method(<Ϧετ>); my $x = <εΧϥ> my ($x) = <Ϧετ>; my @y = <Ϧετ>; my %hash = ( key0 !# 'hoge', key1 !# <εΧϥ>, ); scalar(<Ϧετ>); <εΧϥ>;

Slide 42

Slide 42 text

꞊丗ئهٜ٭ز٤ sub foo { my ($a, $b, $c) = !"; } ס׻ֹמ㲚銧׊י foo(1, 2, 3); ך⽛צ⭳׌ն䌕丗ם׊ס꞊丗⽛צ⭳׊ע؜شؤ泸樋ך׀׾

Slide 43

Slide 43 text

䌕丗ס⹨ׄ⹦׽亠 sub add { my ($x, $y) = !"; return $x + $y; } my $three = add(1, 2); ˝ add(1,2)כ⽛צ⭳׊גכ׀ס䌕丗ע!"כַֹ攐墤ם鿥⮛מ 劲硯׈׿׾ ˝ ׆׿ֿ($x, $y)מ⮆Ⱏ♏⪌׈׿׾

Slide 44

Slide 44 text

䌕丗ס⹨ׄ⹦׽亠 ˝ shift؅✳ֹ ˝ 䌕丗ם׊סshiftע倊랺氳מ!"؅䌕丗מ⹦׾ ˝ my $arg1 = shift;כ׌׾כ!"ס⩝꯽釐碛ֿ$arg1מ♏⪌ ׈׿׾ ˝ !"ע鿥⮛םסך ˝ my $arg1 = $_[0]ך僃⮣ס䌕丗מؓؠجت׌׾׆כ׵ך׀ ׾

Slide 45

Slide 45 text

䌕丗⭚杼ؕظؔ؛ّ sub func1 { my ($arg1, $arg2, %args) = !"; my $opt1 = $args{opt1}; my $opt2 = $args{opt2}; } func1('hoge', 'fuga', opt1 !# 1, opt2 !# 2); 僃䏲מ%argsכ⹨ׄ׾׆כך泸樋⺎耆ם⺲⯥♀׀䌕丗؅㲔杯 ך׀׾

Slide 46

Slide 46 text

⡁ס鲭׊亠 ˝ returnך鲭׎׾ֿյ泸樋⺎耆 ˝ 泸樋׊ג㕙⺬ע僃䏲מ鍐❫׈׿ג䌋ס磵冽ֿ鲭׽⡁כם׾ ˝ 䙫㍲ֿ؂־׽ט׼ׂם׾סך傴׀ױ׊׺ֹ

Slide 47

Slide 47 text

ٓةٖ٭ٜبتطّ ˝ قشآ٭ة package Example!"Greeter; כ傴ׂכյ♓꡸סخ٭تؤ٭غעExample!"Greeterכַֹ⺲⯥ 狜ꝴמ㷯׌׾ قشآ٭ةכע꞊丗ס⺲⯥ֿ䢥㷯׌׾⩝յכ縒ֻ׾כ荁ַ

Slide 48

Slide 48 text

ٓةٖ٭ٜبتطّ ˝ قشآ٭ة package A; sub foo { !!" } package B; sub bar { !!" } א׿ב׿A!"foo()B!"bar()ך꞊丗؅⹆拨ך׀׾

Slide 49

Slide 49 text

ٓةٖ٭ٜبتطّ哭釐 ˝ use Foo!"Bar!"Baz ˝ lib/Foo/Bar/Baz.pmֿ鐆ײ鱮ױ׿յFoo!"Bar!"Baz⺲ ⯥狜ꝴֿ⛼׼׿׾ ˝ 1FSMס㲔车نٜؒؕע.plٓةٖ٭ٜע.pm䦡䍖㯸 ˝ 㲔ⳉך傴ׂסע׮כ؆ל.pm

Slide 50

Slide 50 text

ٓةٖ٭ٜبتطّ哭釐 ˝ VTF׊גכ׀סنٜؒؕס䫒碟⩝ע@INCכַֹءٞ٭فٜם攐 墤㚺丗מ劲硯׈׿יַ׾ ˝ 䜉綗氳מյوٞةؘؠع泡┖ס./lib؅@INCמ⪌׿׾׻ֹ啶 䡗׈׿יַ׾ ˝ @INC؅泡䫘䳩⛼׊ג׽յperl -Ilibך颯Ⳃ׌׾ ˝ perldoc -f useperldoc -v @INC

Slide 51

Slide 51 text

⪯㑔氳םٓةٖ٭ٜ package Foo!"Bar!"Baz; use strict; use warnings; # ͜ͷύοέʔδͷ֎͔Β͸ Foo!"Bar!"Baz!"public_function ͰΞΫηεͰ͖Δͧ sub public_function { !!# } # ඇެ։ͳؾ෼ͷϝιου͸ _ Ͱ͸͡ΊΔͧɻؾ෼͚ͩͳͷͰ֎͔ΒΞΫηε΋Ͱ͖ͪΌ͏͕ɻ sub _private_function { !!# } # Ϟδϡʔϧͷ࠷ޙʹ͸͔ͳΒͣਅ஋Λه͢ɻͦ͏͠ͳ͍ͱ use ͕ࣦഊ͢Δͧɻ 1;

Slide 52

Slide 52 text

鉮鐄 ˝ VTF.0%6-&GPP CBSךٓةٖ٭ٜמ榟ֻיַ׾꞊丗؅ؕ ٤َ٭عך׀׾ ˝ 儖䎎ע׵ֹ㵼׊娆榫氳ך邾ꥭדֿյ׆ס杼鉮ך㍭׼םַ ˝ VTFס䌕丗ם׊ך׵ⳏ䣆מؕ٤َ٭ع׊יׂ׿׾ٓةٖ٭ٜ׵ ֵ׾ ˝ %BUB%VNQFS+40/םל

Slide 53

Slide 53 text

؛هةؘؠع䧗⺸ ˝ 1FSMע׵כ׵כ؛هةؘؠع䧗⺸銧鏤כ׊י㡎ױזג؂ׄךע םַסך䏲♀ׄ ˝ ֿյ俊鵟מ✳ֻ׾ ˝ قشآ٭ةכٛنؒٝ٤تֿ؂־זיַ׿ףյ׮ׯ؜ف٭ך׀ ׾

Slide 54

Slide 54 text

׆׆ך؛هةؘؠع䧗⺸מחַי縒 ֻ׻ֹ

Slide 55

Slide 55 text

؛هةؘؠع䧗⺸כע ˝ ׌ׇׂ癨ⶡמ銧ֻףظ٭ذ啶鵰כ䣆禈׀؅┉稇מ׊ג׵ס ˝ ؛هةؘؠعעؠٚت־׼榟䡗׈׿׾ ˝ ؛هةؘؠعעظ٭ذ؅䧏ח ˝ ؠٚتמעظ٭ذמ㵚׌׾䣆禈׀ْخشغֿ㲊紶׈׿י ַ׾

Slide 56

Slide 56 text

1FSMמֽׄ׾001 001מֽׄ׾榫鏤 1FSMךס榫鏤 ؠٚت قشآ٭ة ْخشغ قشآ٭ةמ㲊紶׈׿ג꞊丗 ؛هةؘؠع قشآ٭ةמCMFTT ׈׿גٛن ؒٝ٤ت

Slide 57

Slide 57 text

CMFTT ˝ CMFTTֿ؛هةؘؠع䧗⺸1FSMמֽׄ׾僃䏲ס氧㕙☔擻 # ͳΜ͔σʔλ͕͋Δʢී௨͸ϋογϡϦϑΝϨϯεʣ my $data = { name !" 'motemen' }; # σʔλʹύοέʔδΛඥ෇͚Δͱ my $self = bless $data, 'Hatena!#Engineer'; # ϝιου͕ݺ΂Δʂ ͜͜Ͱ͸ Hatena!#Engineer!#tweet $self!$tweet();

Slide 58

Slide 58 text

͍͍͔ɺΈΜͳ ɹɹɹɹɹɹɹɹ ƅшƅ ) ɹɹɹɹɹɹɹɹ(|ɹy |) ϋογϡϦϑΝϨϯεͱ package Ͱ͸खଓ͖ܕϓϩάϥϛϯά͔͠Ͱ͖ͳ͍͕ ɹɹɹɹɹ {}ɹ (ƅшƅ)ɹpackage ɹɹɹɹɹɹɹʘʗ|ɹy |ʘʗ ɹɹɹɹೋͭ߹Θ͞Ε͹OOPͱͳΔ ɹɹɹɹɹɹɹɹ(ƅшƅ)ɹ bless ɹɹɹɹɹɹɹɹ(ʘʗʘʗ

Slide 59

Slide 59 text

ؤ٤تعٚؠذ ˝ ؤ٤تعٚؠذ׵舅⮆ך傴ׂն俊鵟עOFXכַֹ⺲⯥؅✳ֹ ˝ ֿյאַֹֹ⯆硜ֵֿ׾؂ׄךעםַն鷿ֹ⺲⯥סؤ٤تع ٚؠذ؅⛼׾׆כ׵ך׀׾

Slide 60

Slide 60 text

ؤ٤تعٚؠذ package Person; use strict; use warnings; sub new { my ($class, %args) = !"; return bless \%args, $class; }

Slide 61

Slide 61 text

✳ַ亠 my $person = Person!"new(age !# 18); # { age !# 18 } ͕ Person ʹ bless ͞Εͨ΋ͷ

Slide 62

Slide 62 text

✳ַ亠 ˝ 1FSTPOOFX BHF ע1FSTPOOFX 1FSTPO BHF ס矴辉啶乃 ˝ ׆ֹ׷זיؠٚتْخشغ؅㲊紶׌׾ ˝ CMFTT׈׿יַי׵ـشبٖٛنؒٝ٤تךֵ׾׆כמ㚺؂׽ע םַ ˝ QFSTPO\BHF^ך╈骰מؓؠجت׌׾׆כ׵⺎耆

Slide 63

Slide 63 text

ْخشغ package Person; use strict; use warnings; sub new { my ($class, %args) = !"; return bless \%args, $class; } sub age { my ($self) = !"; return $self!#{age}; } sub incr_age { my ($self) = !"; $self!#{age}!$; }

Slide 64

Slide 64 text

ْخشغ $person!"incr_age; ˝ QFSTPOJODSBHF@עQFSTPOסCMFTT⩝ךֵ׾1FSTPO؅ג לזיյ磵㷀1FSTPOJODS@BHF QFSTPO כ⺱喋 ˝ ׆ֹ׷זיؕ٤تذ٤تْخشغֿ㲊紶ך׀׾

Slide 65

Slide 65 text

ْخشغ⽛צ⭳׊ױכ״ # ͜ͷೋ͕ͭ౳Ձ Class!"method($arg1, $arg2); Class!#method('Class', $arg1, $arg2); # ͜ͷೋ͕ͭ౳Ձ $object!"method($arg1, $arg2); Class!#method($object, $arg1, $arg2);

Slide 66

Slide 66 text

禆䤔 package Animal; use strict; use warnings; sub new { !!" } sub walk { !!" } 1; package Dog; use strict; use warnings; use parent 'Animal'; 1;

Slide 67

Slide 67 text

禆䤔 my $dog = Dog!"new(); $dog!"walk(); # Animal!#walk ͕ݺ͹ΕΔ ˝ ☼磝ײכ׊יע⺎耆דׄלֵױ׽僃鲣ע✳؂׿יַםַ ˝ 1FSM舅⛮ֿ*%&סئَ٭ع؅⹨ׄט׼ַ扛ַ؂ׄךעםַ ˝ 邾ꥭמם׾

Slide 68

Slide 68 text

؛هةؘؠع䧗⺸ױכ״ ˝ 䣆⛼׽䚉ֵר׿׾؛هةؘؠع䧗⺸ ˝ قشآ٭ةמ䣆禈׀؅㲊紶 ˝ CMFTTךظ٭ذכ磵צחׄ׾ ˝ ؤ٤تعٚؠذע舅⮆ךחׂ׾յ؛هةؘؠع׵舅⮆ך⛼׾ ˝ ؛هةؘؠع䧗⺸겧מ⽛צ⭳׎׾׻ֹם矴辉

Slide 69

Slide 69 text

➘⮵ם$1"/ٓةٖ٭ٜ package Foo; use strict; use warnings; use Class!"Accessor!"Lite ( new !# 1, ro !# ['bar'], ); 1; my $foo = Foo!"new(bar !# 1); # new Ͱ͖ͯΔ $fop!"bar; # bar ϝιου΋ੜ͑ͯΔ

Slide 70

Slide 70 text

طتع طتع؅傴ׂؙؤبتطّ׵׀ה؆כ丝זיַ׾ ˝ QSPWFכַֹطتع㲔车榫סؤُ٤غֿ⺱卲׈׿יַ׾ ˝ طتعעUظؔٝؠعٛ♓┖מ糋ׂ ˝ 䦡䍖㯸עU╈骰ע1FSM

Slide 71

Slide 71 text

طتع use strict; use warnings; use Test!"More; use Person; my $person = Person!#new(age !$ 18); is $person!#age, 18, '࠷ॳ͸18ࡀ'; $person!#incr_age; is $person!#age, 19, 'incr_age ݺΜͩΒ19ࡀ'; done_testing;

Slide 72

Slide 72 text

طتع % prove -Ilib -v t/Person.t t/Person.t !" ok 1 - ࠷ॳ͸18ࡀ ok 2 - incr_age ݺΜͩΒ19ࡀ 1!"2 ok All tests successful. Files=1, Tests=2, 0 wallclock secs ( 0.01 usr 0.01 sys + 0.04 cusr 0.00 csys = 0.06 CPU) Result: PASS

Slide 73

Slide 73 text

5FTU$MBTT package t!"Person; use strict; use warnings; use parent 'Test!"Class'; sub setup : Test(setup) { # ͳʹ͔ෆࢥٞͳຐ๏Ͱؔ਺໊ͷ͋ͱʹΞϊʔςʔγϣϯͰ͖Δ # ֤ςετલͷηοτΞοϓʢม਺ΛΫϦΞͨ͠Γͱ͔ʣ } sub incr_age : Tests { is !!#; }

Slide 74

Slide 74 text

כַֹ׆כך ˝ 껮ׄ餉דׄל1FSMס㓹灄־׼؛هةؘؠع䧗⺸وٞءِٚ٤ء ס鎇ױך׊ױ׊ג ˝ 1FSMמֽׄ׾8FCؓوٛס鎇׵ך׀׾כ荁־זגׄל侇ꝴ氳 מ☪㍑ע׆׆ױך ˝ 全鶚־׼ַ׻ַ׻ز٭ّמ⪌זיַׂ׆כמם׽ױ׌ն⼽׽ס עים炘⿦؅ל؆ל؆갔זיׂד׈ַ ˝ ײ؆ם⨣׊ׂ䷷ֻיׂ׿׾כ䓙ַױ׌