ããŒã¿åŠçã®ããŒãºãå¢ãäžãPerlã¯ãã®æè»æ§ãšåŒ·åãªããã¹ãåŠçèœåã§ããžãã¹çã«äžå¯æ¬ ãªååšã§ãããã®èšäºã§ã¯ãçæéã§Perlã®ãšãã»ã³ã¹ãã€ããããä»æ¥ã®ããŒããPerl 10åã§è§£èª¬ãããå±ãããŸããPerlã®åºç€ããå¿çšãã³ãã¥ããã£æ å ±ãŸã§ãèŠçŽããããžãã¹ããŒãœã³ãããã«Perlã®ç¥èã掻çšã§ããããã¬ã€ãããŸããPerlã®åºæ¬ææ³ãããã°ã©ã äœæã®ã³ãããããŠéå®ãããªãœãŒã¹ãŸã§ãå æ¬çã«è§£èª¬ããŸãã詳现ã¯ç®æ¬¡ãåç §ããŠãå¹ççãªPerlåŠç¿ãå§ããŸãããã
1. ã¯ããã«ïŒPerlãšã¯ïŒ
Perlã¯ã1987幎ã«Larry Wallã«ãã£ãŠäœãããããã°ã©ãã³ã°èšèªã§ããããã¹ãåŠçã®èœåã«åªããŠãããæ£èŠè¡šçŸã匷åã«ãµããŒãããŠããããšã§ç¥ãããŠããŸãããã®æè»æ§ãšå€æ©èœæ§ãããå€ãã®éçºè ã«é·å¹Žæçšããç¶ããŠããŸãã
èšèªã®èšèšææ³ã¯ããThere’s more than one way to do itãïŒããæ¹ã¯1ã€ãããªãïŒã§ãããéçºè ãåé¡è§£æ±ºã«å€æ§ãªã¢ãããŒããè©Šã¿ãããšã奚å±ããŠããŸãããã®ç念ã«åºã¥ããPerlã¯TMTOWTDIïŒTim ToadyïŒãšç¥ãããããšããããŸãã
Perlã¯ã¹ã¯ãªããèšèªã®ã«ããŽãªãŒã«å±ããŠãããCèšèªã®åœ±é¿ãåããªããããã·ã§ã«ã¹ã¯ãªãããawkãsedã®å©ç¹ãçµã¿åãããŠãããã°ã©ãã³ã°ãããç°¡åãã€è¿ éã«è¡ããããã«èšèšãããŠããŸãã
1.1 Perlã®æŽå²ãšç¹åŸŽ
Perlã®æŽå²ã¯1980幎代ãŸã§ããã®ãŒããŸããUNIXã®ã·ã¹ãã 管çã容æã«ããããããšãããããã¹ãåŠçãèªååããããã®ããŒã«ãšããŠéçºãããŸãããããŒãžã§ã³ã®ã¢ããã°ã¬ãŒããšå ±ã«ããŠã§ãããã°ã©ãã³ã°ãã·ã¹ãã 管çããã€ãªã€ã³ãã©ããã£ã¯ã¹ãªã©å€å²ã«ãããåéã§äœ¿çšãããããã«ãªããŸããã
Perlã®äž»ãªç¹åŸŽãšããŠã¯ãå§åçãªããã¹ãåŠçèœåãè±å¯ãªã©ã€ãã©ãªïŒCPANïŒãã³ã³ããã¹ãã«å¿ããåäœãªã©ãæããããŸãããŸããCGIã¹ã¯ãªããã®æžã蟌ã¿ã«ãããŠéåžžã«æå¹ãªèšèªãšããŠãç¥ãããŠãããåæã®ãŠã§ãéçºã«è²¢ç®ããŸããã
ã¹ã¯ãªããèšèªãšããŠã®å©äŸ¿æ§ã«å ããæ¡åŒµæ§ãPerlã®éèŠãªç¹åŸŽã§ãããªããžã§ã¯ãæåããã°ã©ãã³ã°ã®ãµããŒãããæ§ã ãªå€éšã©ã€ãã©ãªã®çµã¿èŸŒã¿ãå¯èœãªç¹ããå€ãã®éçºè ã«éžã°ããçç±ã§ãã
1.2 Perlã®çšéïŒãªãä»ã䜿ãããã®ã
Perlã¯ããã®åŒ·åãªããã¹ãåŠçèœåã®ãããã§ããã°ãã¡ã€ã«ã®è§£æãã¬ããŒãçæãããŒã¿å€æã¿ã¹ã¯ãªã©ãå€çš®å€æ§ãªã·ããªãªã§æŽ»èºããŠããŸãããŸããWebã¹ã¯ãªããããµãŒããŒç®¡çã®èªååãšãã£ãåéã§ãé »ç¹ã«çšããããŠããŸãã
çŸå Žã§å³åº§ã«åœ¹ç«ã€ã¹ã¯ãªãããçæéã§äœæã§ããããšããããããã°ã©ãã®éå ·ç®±ããšããŠå€ãã®ã·ã¹ãã 管çè ãããããããŒã«éå®ãããŠããŸããå¿æ¥åŠçœ®çãªã¿ã¹ã¯ã ãã§ãªããäžèŠæš¡ãã倧èŠæš¡ã®ã¢ããªã±ãŒã·ã§ã³ã®éçºã«ã䜿ãããŠããŸãã
匷åãªã³ãã¥ããã£ãšCPANã®ã©ã€ãã©ãªãè±å¯ã«ãããããå¿ èŠãªæ©èœãçŽ æ©ãèŠã€ããŠå°å ¥ããããšãã§ããã®ããPerlãçŸåšã§ã奜ãã§äœ¿ãããçç±ã®äžã€ã§ãã
1.3 Perlã®ç°å¢èšå®ãšã€ã³ã¹ããŒã«
Perlãå§ããåã«ãæåã®ã¹ããããšããŠç°å¢èšå®ãšã€ã³ã¹ããŒã«ãå¿ èŠã§ããå€ãã®UNIXç³»ã®ãªãã¬ãŒãã£ã³ã°ã·ã¹ãã ã«ã¯Perlãäºãã€ã³ã¹ããŒã«ãããŠããŸãããWindowsãä»ã®OSã䜿çšããŠããå Žåã¯ãPerlã®å ¬åŒWebãµã€ãããã€ã³ã¹ããŒã©ãããŠã³ããŒãããããšã«ãªããŸãã
ã€ã³ã¹ããŒã«åŸã¯ãã³ãã³ãã©ã€ã³ããperlã®ããŒãžã§ã³ã確èªããããšãã§ããŸããããã¯ãperl -vããšå ¥åããããšã§è¡ãããšãã§ããPerlãæ£ããã€ã³ã¹ããŒã«ãããŠãããã確èªããç°¡åãªæ¹æ³ã§ãã
ãŸããéçºã«ã¯Perlã®ã€ã³ã¿ããªã¿ãŒãå©çšããŸããããããªãéçºã®äŸ¿å®ãå³ãããã«ã¯ãIDEããšãã£ã¿ã®èšå®ã«å¯Ÿå¿ãããã©ã°ã€ã³ãã€ã³ã¹ããŒã«ãããšè¯ãã§ãããã
1.4 Perlã®åºæ¬çãªæ§æãšããŒã¿å
Perlã®æ§æã¯ãCãsedãawkã«åœ±é¿ãåããŠããŸããå€æ°ã«ã¯ã¹ã«ã©ãŒãé åãããã·ã¥ã®3çš®é¡ããããŸããã¹ã«ã©ãŒå€æ°ã¯$èšå·ã§å§ãŸãã1ã€ã®èŠçŽ ïŒæååãæ°å€ãŸãã¯åç §ïŒãä¿æããŸããé åå€æ°ã¯@èšå·ã§å§ãŸããé åºä»ããããèŠçŽ ã®ãªã¹ããä¿æããŸãã
ããã·ã¥å€æ°ã¯%èšå·ã§å§ãŸããããŒãšå€ã®ãã¢ã®éåãä¿æããŸããPerlã§ã¯ããããã®ããŒã¿åãæè»ã«ããããŠåŒ·åãªãã«ãã€ã³é¢æ°ãçšããŠæäœããããšãã§ããŸããäŸãã°ããªã¹ãã®èŠçŽ ã«å¯ŸããŠç¹°ãè¿ãåŠçãè¡ãéã«ã¯ãforeachã«ãŒããå©çšããŸãã
ããã°ã©ã ã®å¶åŸ¡æ§é ã«ã¯ifãunlessãwhileãuntilãforãªã©ããããç¶æ³ã«å¿ããŠæé©ãªå¶åŸ¡ãããŒãæ§ç¯ããããšãã§ããŸããæ£èŠè¡šçŸãPerlã®åŒ·åãªæ©èœã®äžã€ã§ãããããã¹ãæäœãè¡ãéã«ã¯ãã®æ©èœãéå®ãããŸãã
2. Perlã®åºæ¬ææ³
Perlã¯ããã¹ãåŠçã«åªããã¹ã¯ãªããèšèªã§ãããã·ã¹ãã 管çãWebããã°ã©ãã³ã°ã«åºãå©çšãããŠããŸãããã®å匷ãã¯æè»ãªææ³ãšãå®çšæ§ã«å¯ãã æ©èœã«ãããŸãããã®ã»ã¯ã·ã§ã³ã§ã¯ãPerlã³ãŒããæžãäžã§å¿ é ã®åºæ¬ææ³ã«ã€ããŠè§£èª¬ããŸãã
Perlã®å€æ°ã¯æ確ãªå宣èšãå¿ èŠãšãããã¹ã«ã©ãŒãé åãããã·ã¥ãšãã£ãïŒçš®é¡ãååšããŸãããŸããPerlã¯ã³ã³ããã¹ãã«å¿ããŠå€æ°ã®åãèªåçã«å€æãããªã©ãæè»ãªåã·ã¹ãã ãæã¡ãŸããããã«ãã£ãŠå¹ççãªããã°ã©ã ãç°¡åã«èšè¿°ããããšãå¯èœã§ãã
ãŸãPerlã¯ãã³ãŒãå ã§ã®æ¡åŒµæ§ãšç¶æ管çã®å®¹æãã«ãçŠç¹ãåœãŠãŠããŸããå©çšè ãå¢ããããšã§ãããå€ãã®ã©ã€ãã©ãªãã¢ãžã¥ãŒã«ãå ±æãããPerlã³ãã¥ããã£ã¯ãã®å©äŸ¿æ§ãåäžããç¶ããŠããŸãã
2.1 å€æ°ãšãªãã¬ãŒã¿ãŒ
Perlã§ã¯ã¹ã«ã©ãŒå€æ°ã’$’ãé åã’@’ãããã·ã¥ïŒé£æ³é åïŒã’%’ã®èšå·ã§è¡šçŸããŸããã¹ã«ã©ãŒå€æ°ã¯åäžã®å€ïŒæ°å€ãæååïŒãä¿æããé åã¯é åºä»ãã®å€ã®ãªã¹ããããã·ã¥ã¯ããŒãšå€ã®ãã¢ãæ±ããŸãã
æŒç®åã«é¢ããŠã¯ãPerlã¯æ°å€æŒç®ãšæååæŒç®ãåºå¥ããŸããäŸãã°ã‘.’ã¯æååã®é£çµãè¡ãã’+’ã¯æ°å€ã®å ç®ãè¡ããŸããç解ããããæŒç®åã®äœ¿çšã«ãã£ãŠãèªã¿ãããä¿å®ããããã³ãŒãäœæãä¿ãããŸãã
ãŸãPerlã®ãªãã¬ãŒã¿ãŒã¯ãçµã¿èŸŒã¿é¢æ°ãšåãããŠéåžžã«åŒ·åã§ããäŸãã°ããã¡ã€ã«æäœãããŒã¿ããŒã¹ã¢ã¯ã»ã¹ãã·ã¹ãã ã³ãŒã«ãªã©å€å²ã«ããããŸãããããã®æ©èœã¯Perlãå®åã§éåžžã«æçšãªèšèªãšããŠããŸãã
2.2 å¶åŸ¡æ§é ïŒifæãšã«ãŒãåŠç
å¶åŸ¡æ§é ã¯ä»»æã®æ¡ä»¶ã«åºã¥ããŠã³ãŒãã®å®è¡ãããŒãå¶åŸ¡ããŸããPerlã®ifæã¯ä»ã®å€ãã®ããã°ã©ãã³ã°èšèªãšåæ§ã«æ©èœããæ¡ä»¶ãçã®æã«ç¹å®ã®ã³ãŒããããã¯ãå®è¡ããŸãã
ã«ãŒãåŠçã«ãããŠã¯ã’foreach‘ã’for‘ã’while‘ã’until‘ ãšãã£ãæ§é ã䜿ãããŸãããããã¯äžé£ã®åŠçãç¹°ãè¿ãå®è¡ããããã«äŸ¿å©ã§ããåã«ãŒãã¿ã€ãã¯ç°ãªãã±ãŒã¹ã«å¿ããŠäœ¿çšãããããã°ã©ãããã粟床ã®é«ãã³ãŒããæžãæå©ããããŸãã
Perlã®å¶åŸ¡æ§é ã¯ãã®ä»ã«ãã’next‘ã’last‘ã’redo‘ãšãã£ãã«ãŒãã³ã³ãããŒã«æŒç®åã䜿çšããŠé«åºŠãªã³ã³ãããŒã«ãæäŸããŸãããããã®æŒç®åã¯ã«ãŒãã®æµããå€æŽããããè€éãªã¢ã«ãŽãªãºã ã®å®è£ ãå¯èœã«ããŸãã
2.3 ãµãã«ãŒãã³ïŒã³ãŒããå¹ççã«
ãµãã«ãŒãã³ã¯äžé£ã®åœä»€ããŸãšããŠååãä»ããã³ãŒãã®åå©çšãå¯èœã«ããŸããPerlã§ã¯’sub‘ããŒã¯ãŒãã䜿ã£ãŠãµãã«ãŒãã³ãå®çŸ©ããåŒæ°ã®æž¡ãæ¹ãéåžžã«æè»ã§ãã
ãµãã«ãŒãã³ã䜿çšããããšã§ã³ãŒããã¢ãžã¥ãŒã«åããããšã©ãŒã®çºçãæžããã¡ã³ããã³ã¹ã容æã«ããŸãããŸããå¯èªæ§ãåäžãããããžã§ã¯ãã«åå ããä»ã®éçºè ãã³ãŒãã®ç解ãšå€æŽãè¡ãããããªããŸãã
Perlã§ã¯åŒæ°ã®ãªã¹ãã§èªåçã«ãµãã«ãŒãã³ãåŒã³åºã@”_”é åã䜿ãããŸããããã¯ãåŒã³åºãåŽããæäŸãããåŒæ°ããµãã«ãŒãã³å éšã§å©çšããéã«æçšã§ãã
2.4 æ£èŠè¡šçŸïŒããã¹ãåŠçã®åŒ·åãªããŒã«
Perlã®æ倧ã®ç¹åŸŽã®äžã€ã匷åãªæ£èŠè¡šçŸã®ãµããŒãã§ããããã¯ããã¹ãã®æ€çŽ¢ã眮æã解æãè¡ããšãã«éåžžã«æå¹ã§ããPerlã®æ£èŠè¡šçŸã¯ãå€æ§ãªãã¿ãŒã³ãããã³ã°æ©èœãšãæè»ãªãããæ¡ä»¶ãæäŸããŸãã
Perlã®æ£èŠè¡šçŸã§ã¯ã‘=~’æŒç®åãçšããŠæååã«ãã¿ãŒã³ãããã³ã°ãè¡ããŸãããŸããã©ããæŒç®åã§ç¹å®ã®ãã¿ãŒã³ããããããéšåãæœåºããããšãã§ããŸãããããã®æ©èœã«ãããè€éãªããã¹ãåŠçã容æã«ãªããŸãã
å®éã®ã³ãŒãã§ãã䜿çšãããã®ã¯ã‘s///’ã«ãã眮æã’grep‘ã’map‘ãšãã£ããªã¹ãåŠçé¢æ°ãšã®çµã¿åããã§ãããããã¯ã³ãŒãå ã®ããã¹ããå¹ççã«æäœããããã®åŒ·åãªéå ·ãšãªããŸãã
3. Perlã§ããã°ã©ã ãæžãã
3.1 Hello, World!ïŒæåã®Perlã¹ã¯ãªãã
PerlãåŠã¶æåã®äžæ©ã¯ãäŒçµ±çãªãHello, World!ãããã°ã©ã ãæžããå®è¡ããããšããå§ããŸãããã®ã·ã³ãã«ãªäžè¡ã®ã³ãŒãã¯ãããã°ã©ãã³ã°èšèªã®åºæ¬çãªæ§æãšå®è¡æ¹æ³ãç解ããããã®åºçºç¹ãšãªããŸãã
Perlã§ãHello, World!ããåºåããã«ã¯ãããã¹ããšãã£ã¿ã«æ¬¡ã®ã³ãŒããå
¥åããŸãïŒprint "Hello, World!\n";
ããã®ã¹ã¯ãªããã¯printé¢æ°ã䜿çšããŠæååãåºåããæ¹è¡æå(\n)ã§è¡æ«ãè¡šããŸãã
ãã®ã¹ã¯ãªãããä¿åããPerlã®ã€ã³ã¿ããªã¿ã䜿ã£ãŠå®è¡ãããšãã³ã³ãœãŒã«äžã«ãHello, World!ãã衚瀺ãããŸããããã§ãPerlããã°ã©ãã³ã°ã®åºæ¬ãåŠã³å§ããããšãã§ããŸãã
3.2 å ¥åãšåºåïŒãã¡ã€ã«ã®èªã¿æžã
PerlãçšããŠãã¡ã€ã«ã®èªã¿æžããè¡ãããšã¯ãå€ãã®å®åã§é »ç¹ã«äœ¿çšãããŸãããã¡ã€ã«æäœã¯ããŒã¿åŠçãã¬ããŒãçæã«äžå¯æ¬ ã§ãã
ãã¡ã€ã«ãéãã«ã¯ãopené¢æ°ã䜿çšããŸãããã¡ã€ã«ãã³ãã«ãšãã¡ã€ã«ã¢ãŒãããã¡ã€ã«åãæå®ããŸããäŸãã°ãopen(my $fh, '<', 'filename.txt');
ãšããã³ãŒãã§ãã¡ã€ã«ãèªã¿èŸŒãã¢ãŒãã§éããŸãã
ãã¡ã€ã«ããã®èªã¿åãã¯ãwhileã«ãŒããš<$fh>
ã䜿çšããŠè¡ãããŸãããŸããåºåã¯printé¢æ°ããã¡ã€ã«ãã³ãã«ã«å¯ŸããŠè¡ãããšã§ãæå®ãããã¡ã€ã«ã«ããŒã¿ãæžã蟌ãããšãã§ããŸãã
3.3 ãšã©ãŒåŠçãšãããã°ææ³
ãšã©ãŒã¯ããã°ã©ãã³ã°ã«ãããŠé¿ããããªãèŠçŽ ã§ãããPerlã«ãããŠãäŸå€ã§ã¯ãããŸãããé©åãªãšã©ãŒåŠçãšãããã°ã¯ãã¹ã¯ãªããã®ä¿¡é Œæ§ãé«ããããã«å¿ èŠãªã¹ãã«ã§ãã
ãšã©ãŒããã£ããããåºæ¬çãªæ¹æ³ã¯ãå®è¡æã«ããããdieãé¢æ°ãŸãã¯ãwarnãé¢æ°ã®äœ¿çšã§ããããã«ããããšã©ãŒã¡ãã»ãŒãžã衚瀺ããããã°ã©ã ãçµäºããŸãããŸãããšã©ãŒãã³ããªã³ã°ãã«ã¹ã¿ãã€ãºããããã«ãevalãããã¯ã䜿ãããšãã§ããŸãã
ãããã°ã«ã¯ãPerlã®ãããã¬ã䜿ããããŸãã¯printé¢æ°ã䜿ã£ãŠå€æ°ã®å 容ãåºåãããªã©ã®æ¹æ³ããããŸãã綿å¯ãªãã¹ããšãšã©ãŒã®æ€èšŒã¯ãã³ãŒãã®å質ãç¶æããããã«äžå¯æ¬ ã§ãã
3.4 Perlã¹ã¯ãªããã®å®è¡ãšè©Šè¡é¯èª€
Perlã¹ã¯ãªãããå®è¡ããã«ã¯ãã³ãã³ãã©ã€ã³ãããperlãã³ãã³ãã«ç¶ããŠãã¡ã€ã«åãæå®ããŸããäŸãã°ãperl script.pl
ãšå
¥åãããšã察å¿ããPerlã¹ã¯ãªãããå®è¡ãããŸãã
è©Šè¡é¯èª€ã¯ããã°ã©ãã³ã°ã«ãããŠåŠç¿ãšç解ãæ·±ããéèŠãªããã»ã¹ã§ããPerlã«ãããŠããããŸããŸãªã³ãŒãã®æçãè©Šãããã®æåã芳å¯ããããšã§ãPerlã®æ©èœãšãã®äœ¿çšæ³ãããããææ¡ã§ããŸãã
Perlã«ã¯è±å¯ãªããã¥ã¡ã³ãããããå ¬åŒã®ããã¥ã¡ã³ããŒã·ã§ã³ããªã³ã©ã€ã³ãã©ãŒã©ã ãããŸããŸãªãã¥ãŒããªã¢ã«ãéããŠãè¿ éã«æ å ±ãåŸãããšãå¯èœã§ããå®è·µãéããŠç¿åŸããããšããPerlããã°ã©ãã³ã°ããã¹ã¿ãŒããæãå¹æçãªæ¹æ³ã®äžã€ã§ãã
4. Perlã®å¿çš
4.1 Webã¹ã¯ãªããã£ã³ã°ãšCGIããã°ã©ãã³ã°
ããããPerlã¯ãã®ããã¹ãåŠçèœåãçãããWebãµãŒããšé£æºããCGIã¹ã¯ãªããã£ã³ã°ã§ãåºãå©çšãããŠããŸããé«åºŠãªããã¹ã解æãããŒã¿åŠçã«åªããHTTPãªã¯ãšã¹ããHTMLãã©ãŒã ã®ããŒã¿ãå¹çè¯ãæ±ãããšãã§ããŸãã
CGIãšã¯ãCommon Gateway Interfaceãã®ç¥ã§ããŠã§ããµãŒããšã¢ããªã±ãŒã·ã§ã³ïŒPerlã¹ã¯ãªãããªã©ïŒãã€ãªãä»çµã¿ã®ããšãæããŸããPerlã¯ãã®æ±çšæ§ãšæ¡åŒµæ§ã«ãããŠãåæã®Webéçºã§éå®ãããŸããã
Perlã¹ã¯ãªããã¯ããã©ãŒã ããŒã¿ã®åãåããEã¡ãŒã«ã®éä¿¡ãããŒã¿ããŒã¹ãžã®æ¥ç¶ãšãã£ãäžè¬çãªWebã¢ããªã±ãŒã·ã§ã³æ©èœãæ¯èŒçç°¡åã«å®è£ ããããšãã§ãããããWebéçºã«ãããŠã¯äŸç¶ãšããŠãã®äŸ¡å€ãæã£ãŠããŸãã
4.2 ããŒã¿ããŒã¹æäœãšPerl DBI
PerlãçšããããŒã¿ããŒã¹æäœã¯ãPerl DBIïŒDatabase InterfaceïŒã¢ãžã¥ãŒã«ãéããŠè¡ãããŸããDBIã¯ãPerlããã°ã©ã ãããŸããŸãªããŒã¿ããŒã¹ã·ã¹ãã ãšç°¡åã«éä¿¡ã§ããããã«ããæšæºã®ã€ã³ã¿ãŒãã§ãŒã¹ã§ãã
DBIã䜿çšããããšã«ãã£ãŠãPerléçºè ã¯SQLã¯ãšãªãå®è¡ããŠçµæãæäœããã³ãŒããç°¡åã«æžãããšãã§ããŸãããã®éçšã«ãããŠãDBIã¯æ§ã ãªããŒã¿ããŒã¹ãšã³ãžã³ã«å¯ŸããŠåãã³ãŒãã€ã³ã¿ãŒãã§ãŒã¹ãæäŸãããããéçºè ã¯ç¹å®ã®ããŒã¿ããŒã¹äŸåã®APIãåŠã¶å¿ èŠãæžå°ããŸãã
Perl DBIãå©çšããéã«ã¯ãDBIæ¬äœã«å ããŠç¹å®ã®ããŒã¿ããŒã¹ã«å¯Ÿå¿ããDBDïŒDatabase DriverïŒã¢ãžã¥ãŒã«ãã€ã³ã¹ããŒã«ããå¿ èŠããããŸããããã«ãããMySQLãPostgreSQLãOracleãªã©è€æ°ã®ããŒã¿ããŒã¹ã«å¯Ÿå¿ããæè»æ§ãåŸãããŸãã
4.3 ã¢ãžã¥ãŒã«ãšCPANã®å©çš
Perlã®ããäžã€ã®åŒ·åãªæ©èœã¯ãã¢ãžã¥ãŒã«ã®å©çšã«ããããã°ã©ã ã®æ¡åŒµæ§ã§ããPerlã¢ãžã¥ãŒã«ã¯ãç¹å®ã®æ©èœãæäŸããããã®ããã±ãŒãžåãããã³ãŒã矀ã§ããPerlã®å€§ããªé åã®äžã€ã¯ããããã®ã¢ãžã¥ãŒã«ãCPANïŒComprehensive Perl Archive NetworkïŒãšåŒã°ãã巚倧ãªã¢ãŒã«ã€ããã容æã«å©çšã§ããããšã§ãã
CPANã¯äžçäžã®Perléçºè ã®åªåã«ãã£ãŠæ§ç¯ããããªããžããªã§ãããæ°äžã®ã¢ãžã¥ãŒã«ãå ¬éãããèªç±ã«ããŠã³ããŒãããŠå©çšããããšãã§ããŸããããã«ãããéçºè ã¯ãœãããŠã§ã¢ã®è»èŒªã®åçºæãé¿ãã€ã€ããããžã§ã¯ãã®éçºãè¿ éã«é²ããããšãã§ããŸãã
CPANã®ã¢ãžã¥ãŒã«ã䜿çšããã«ã¯ãcpanã³ãã³ããCPAN.pmããŸãã¯ã¢ãã³ãªCPANã¯ã©ã€ã¢ã³ãã§ããcpanmïŒCPANminusïŒãªã©ãçšããŠã€ã³ã¹ããŒã«ããŸããäŸåé¢ä¿ãå«ããŠå¿ èŠãªã¢ãžã¥ãŒã«ã®ååŸãšã€ã³ã¹ããŒã«ãèªåã§è¡ãããããéçºå¹çãé£èºçã«åäžããŸãã
4.4 çŸä»£PerlãšCPANã®ãã¹ããã©ã¯ãã£ã¹
Perlçéã§ã¯ãModern Perlããšããã ãŒãã¡ã³ãããããPerlããã°ã©ãã³ã°ã®ãã¹ããã©ã¯ãã£ã¹ãçŸä»£çãªãã¯ããã¯ãæå±ãããŠããŸãããã®æ°ããèãæ¹ã¯ãPerlã«ãããä¿å®æ§ãå質ãçç£æ§ã®åäžãç®æããŠããŸãã
ãã¹ããã©ã¯ãã£ã¹ãšããŠã¯ãå³å¯ãªãšã©ãŒãã§ãã¯ãèŠåã®æå¹åãã¢ãžã¥ãŒã«ã®ç©æ¥µçãªå©çšãªã©ãæããããŸãããŸããMooseãMooãšãã£ãã¢ãã³ãªãªããžã§ã¯ãæåãã¬ãŒã ã¯ãŒã¯ã®äœ¿çšãæšå¥šãããŠããŸãã
CPANã¯ã¢ãã³Perlã®éçºãæ¯ããéèŠãªè³ç£ã§ããããã«ã¯ãã¹ããã©ã¯ãã£ã¹ã«åŸã£ãŠäœãããå€ãã®ã¢ãžã¥ãŒã«ãæã£ãŠãããéçºè ã¯ãããã掻çšããããšã«ãããããè¯ãPerlããã°ã©ã ãæžãå©ããšãªããŸããPerlã¯æ代ã«å³ããŠé²åããŠããããã®ãã¯ãã«ãªãšã³ã·ã¹ãã ã¯ååéã®éçºè ã匷åã«æ¯æŽãç¶ããŠããŸãã
5. Perlã³ãã¥ããã£ãšãªãœãŒã¹
5.1 æ²ç€ºæ¿ããã©ãŒã©ã ãã¡ãŒãªã³ã°ãªã¹ã
Perlã®åŠç¿è ããããã§ãã·ã§ãã«ãæ å ±äº€æãè¡ãããã®æ²ç€ºæ¿ããã©ãŒã©ã ãã¡ãŒãªã³ã°ãªã¹ããå¹ åºãååšããŸãããããã¯åå¿è ããäžçŽè ãŸã§æ§ã ãªã¬ãã«ã®ãŠãŒã¶ãŒã質åãæè¡çãªèšè«ãè¡ãå Žãšãªã£ãŠããŠãPerlã«é¢ããç¥èãæ·±ããã®ã«åœ¹ç«ã¡ãŸãã
ç¹ã«æåãªãã®ãšããŠãPerlMonksãPerlMavenã®æ²ç€ºæ¿ããããããã°ã©ããŒãæ¥ã ã®éçºã®çåããã¹ããã©ã¯ãã£ã¹ã«ã€ããŠå©èšãæ±ãããããšãã§ããŸãããŸããCPANã®ã³ã¡ã³ãæ¬ã§ã¯å ·äœçãªã¢ãžã¥ãŒã«ã®äœ¿ãæ¹ã«ã€ããŠè³ªåããããšãã§ããŸãã
ã¡ãŒãªã³ã°ãªã¹ãã§ã¯ãPerl 5 PortersãPerl WeeklyãPerl Jobsãªã©ãã¢ã¯ãã£ãã§ãå®æçãªã¢ããããŒããæ±äººæ å ±ãã³ãŒãã£ã³ã°ãã¯ããã¯ãå ±æããŠããŸãããããã®ã³ãã¥ãã±ãŒã·ã§ã³ããŒã«ãå©çšããããšã§ãPerlã³ãã¥ããã£ã«åå ãããããªããŸãã
5.2 Perlã®ããã¥ã¡ã³ããšãã«ã
Perlã«ã¯è©³çŽ°ãªå ¬åŒããã¥ã¡ã³ãããããããã°ã©ããŒãé¢æ°ãæ§æãã¢ãžã¥ãŒã«ã®äœ¿çšæ¹æ³ã«ã€ããŠåŠã¶ããšãã§ããŸããperl.orgãmetacpan.orgã¯Perlã®ããã¥ã¡ã³ãã«ç°¡åã«ã¢ã¯ã»ã¹ããããã®äž»èŠãªãœãŒã¹ã§ãã
ãŸããperldocã³ãã³ãã䜿ãã°ãã€ã³ã¹ããŒã«ãããŠããPerlã®ããŒãžã§ã³ã«å¯Ÿå¿ããããã¥ã¢ã«ãã¢ãžã¥ãŒã«ã®ããã¥ã¡ã³ããã³ãã³ãã©ã€ã³ã§çŽæ¥åç §ããããšãå¯èœã§ããããã¯éçºäžã«è¿ éã«æ å ±ãåŸãããã®éèŠãªããŒã«ã§ãã
å ¥éè çšã®ãªãœãŒã¹ãšããŠã¯ããLearn PerlãããPerl Tutorial Hubããªã©ã®ãŠã§ããµã€ãããããåºæ¬æŠå¿µãã¹ã¯ãªããäœæãPerlã®ããŒã¿æ§é ã®åŠç¿ã«åœ¹ç«ã¡ãŸããè±å¯ãªäŸãšè§£èª¬ã§ãPerlãåŠã¶è ã«åããããããµããŒããæäŸããŠããŸãã
5.3 Perlã®ä»åŸã®å±æãšã¢ããããŒã
Perlã¯å®æçã«ã¢ããããŒããããæ©èœæ¡åŒµãã»ãã¥ãªãã£ã®åŒ·åããã°ä¿®æ£ãè¡ãããŠããŸããããã«ãããããã°ã©ãã³ã°èšèªãšããŠã®Perlã®é åãç¶æã»åäžããçŸä»£ã®éçºç°å¢ã«ãé©å¿ããŠããŸãã
Perlã³ãã¥ããã£ã§ã¯ãå°æ¥ã®Perlã®æ¹åæ§ã«ã€ããŠãè°è«ããããRakuïŒæ§åPerl 6ïŒã®ãããªãPerlã®ç念ãç¶æ¿ãã€ã€ãæ°ããªãã©ãã€ã ãæ©èœãåãå ¥ããŠãããããžã§ã¯ãã泚ç®ãããŠããŸãã
Perlã®éçºã¯ãªãŒãã³ãœãŒã¹ãããžã§ã¯ãã§ãããå€ãã®è²¢ç®è ã掻åããŠãããããPerlã®é²åã¯ã³ãã¥ããã£ã®æèŠãããŒãºãåæ ãããã®ãšãªã£ãŠããŸãããŠãŒã¶ã¯æŽæ°æ å ±ãå®æçã«ãã§ãã¯ããæ°ãããã¬ã³ãã«é©å¿ããŠããããšãæšå¥šãããŸãã
5.4 ã³ãã¥ããã£ã®è²¢ç®ãšãµããŒã
Perlã³ãã¥ããã£ã¯éåžžã«ååçã§ãããŸããŸãªæ¹æ³ã§ããã°ã©ããæ¯ãåã£ãŠããŸããäŸãã°ãCPANïŒComprehensive Perl Archive NetworkïŒã«ã¢ãžã¥ãŒã«ãå¯çš¿ããããšã§ãã³ãŒãã®åå©çšãä¿é²ããå ±éã®åé¡ã解決ããæå©ããããŠããŸãã
ã³ãã¥ããã£ã€ãã³ããããã¯ã¢ãœã³ãå匷äŒãäžçäžã§ããéå¬ãããŠãããPerlã«é¢ããè¬æŒãã¯ãŒã¯ã·ã§ãããéããŠç¥èã®å ±æãæè¡åäžãå³ãããŠããŸãããŸããè²¢ç®è ãéãŸãæ°ããã¢ã€ãã¢ããããžã§ã¯ããçºè¡šããå Žã§ããããŸãã
ãããã®æŽ»åãéããŠãPerlã³ãã¥ããã£ã¯åžžã«æ°é®®ãªåºæ¿ãšæ¯æŽãæäŸãç¶ããŠãããPerlãŠãŒã¶ãŒã«ãšã£ãŠäžå¯æ¬ ãªååšã§ãããããŠãå€ãã®ããã°ã©ããŒã¯ãããã®è²¢ç®ã«ãã£ãŠPerlã®ã¹ãã«ã磚ãäžãããã£ãªã¢ãç¯ããŠããŸãã
6. ãŸãšãïŒPerlã10åã§æŠèŠ³
Perlã¯é·ãæŽå²ãæã€ããã°ã©ãã³ã°èšèªã§ãããã¹ãåŠçã®åŒ·ããæè»ãªæ§æãåºå€§ãªã¢ãžã¥ãŒã«ã®ãšã³ã·ã¹ãã ã§ç¥ãããŠããŸãããã®èšäºã§ã¯ãPerlã®åºç€ãããã€ãŸãã§è§£èª¬ããããã«ããŠè³¢ãPerlãåŠã¶ãããã®ããã®å®è·µçãªãã³ãããããŠåŠã³ãç¶ç¶ããæ¹æ³ã«ã€ããŠèª¬æããŸãã
6.1 PerlãåŠã¶çç±ãšãã®åŒ·ã¿
PerlãåŠã¶æ倧ã®çç±ã¯ãããã¹ãåŠçãšå€§èŠæš¡ãªå ±åäœæ¥ã®èªååã«ãããŠæ矀ã®èœåãããç¹ã§ããè€éãªãã¿ãŒã³ãããã³ã°ãããŒã¿å€æäœæ¥ãçŽæçãªã¹ã¯ãªããã§ç°¡åã«è¡ããŸãããŸããCPANïŒComprehensive Perl Archive NetworkïŒãšåŒã°ããã¢ãžã¥ãŒã«ã®éç©å°ã¯ãPerlã®é åã®äžã€ã§ãã
Perlã®æ§æã¯ãèªç±åºŠãé«ããããã°ã©ãã®å¥œã¿ã«åãããŠãããã¹ã姿ããèªç±ã«å€ããããšãã§ããŸãããã®ãThere’s more than one way to do itããšããå²åŠã¯ãPerlã®å€§ããªç¹åŸŽãšããŠæããããŸãã
Perlã®ã³ãã¥ããã£ã¯æŽ»çºã§ãåå¿è ããäžçŽè ãŸã§ãååãåã£ãŠããŸããããã«ãã¹ã¯ãªããèšèªãšããŠã®æŽå²ãæããå®å®ããŠãããããå€ãã®æ¢åã®ã³ãŒããè³æºãåãå ¥ããããã§ãã
6.2 ä»æ¥ããå§ããPerlãã©ã¯ãã£ã¹
PerlãåŠã³å§ããã«ã¯ãåºæ¬çãªæ§æã«æ £ããããšããã¹ã¿ãŒãããŸããã¹ã«ã©ãŒå€æ°ãé åãããã·ã¥ãå¶åŸ¡æ§é ãæ£èŠè¡šçŸãšãã£ãåºæ¬çãªæŠå¿µãææ¡ããŸãããããªã³ã©ã€ã³ã®ãã¥ãŒããªã¢ã«ãPerlã®ããã¥ã¡ã³ãã掻çšãããšè¯ãã§ãããã
å®è·µã䌎ãåŠç¿ãéèŠã§ããåçŽãªã¹ã¯ãªãããæžããå°ããªãããžã§ã¯ããèªåã§è©Šã¿ãããšãæšå¥šãããŸããäŸãã°ãç°¡åãªæ¥èšã¢ããªã±ãŒã·ã§ã³ãäœæãããªã©ã身è¿ãªåé¡ãPerlã§è§£æ±ºããããšã§ãç¿åŸé床ãäžããŸãããã
ãŸããéçºç°å¢ã¯Perlã®ã€ã³ã¿ã©ã¯ãã£ãã·ã§ã«ã䜿ãããšã§ããªã¢ã«ã¿ã€ã ã§ã®ã³ãŒããã¹ããå¯èœã§ããPerlã®ãšã©ãŒã¡ãã»ãŒãžãæ¯èŒçç解ããããããããããã°ãéããŠåŠç¿ãæ·±ããããšãã§ããŸãã
6.3 Perlã®ãã³ããšã³ã
Perlãç¿åŸããéã®ãã³ããšããŠæãéèŠãªã®ã¯ãå®éã«ã³ãŒããæžããŠã¿ãããšã§ããç¹°ãè¿ãããã°ã©ã ãæžãããšã§ãæ§æãšæ©èœãèªç¶ãšèŠããããŸãããŸããPerlã®å¹ åºãã¢ãžã¥ãŒã«ãè©Šçšããããšãæšå¥šãããŸããããã«ããå¹çè¯ããããå°éçãªã¿ã¹ã¯ãããªããããã«ãªããŸãã
CPANãå©çšããŠãããããåé¡ã«å¯ŸåŠã§ããã¢ãžã¥ãŒã«ãçºèŠããããšã¯ãPerlããã°ã©ãã«ãšã£ãŠéåžžã«æçã§ããã¢ãžã¥ãŒã«ã®ããã¥ã¡ã³ããèªãç¿æ £ãã€ããããšã§ãPerlã®èœåãæ倧éã«åŒãåºãããšãã§ããŸãã
ããã«ãPerlã®ã³ãã¥ããã£ã¯éåžžã«èŠªåã§ãã®ã§ãåé¡ãèµ·ããéã«ã¯ãã©ãŒã©ã ãã¡ãŒãªã³ã°ãªã¹ããQAãµã€ãã掻çšãããšè¯ãã§ããããä»ã®å€ãã®éçºè ãã¡ãéå»ã«çŽé¢ããç¶æ³ã«å¯Ÿãã解決çãå ±æããŠããããšãå€ãã§ãã
6.4 ç¶ç¶çãªåŠç¿ãšæé·ã®é
Perlã®ç¿åŸã¯äžåºŠã®åŠç¿ã§çµãããã®ã§ã¯ãããŸãããPerlã®äžçã¯åžžã«é²åããŠãããããå®æçãªåŠç¿ãšå®è·µãéèŠã§ãããããžã§ã¯ããžã®è²¢ç®ããæ°ããã¢ãžã¥ãŒã«ã®éçºãç®æããåžžã«ã¹ãã«ã¢ãããå³ãããšãæãŸããã§ãã
Perlã®å°éæžç±ããªã³ã©ã€ã³è³æã®èªã¿èŸŒã¿ããããŠå°å ã®Perlã¢ã³ã¬ãŒãºïŒPerlã®ãŠãŒã¶ã°ã«ãŒãïŒãžã®åå ãæé·ãä¿ããŸããããã«ãå®æçã«éå¬ãããPerlé¢é£ã®ã«ã³ãã¡ã¬ã³ã¹ãã¯ãŒã¯ã·ã§ããã«åå ããããšã§ãæ°ããªç¥èãšãããã¯ãŒãã³ã°ã®ãã£ã³ã¹ãåŸãããŸãã
æåŸã«ãç¥èãå ±æããããšã倧åã§ããããã°ãæžããããã³ãŒããGitHubã§å ¬éããããšã§ããã£ãŒãããã¯ãåŸãããšãã§ãããããªãæé·ã«ç¹ãããŸããæããããšã¯åŠã¶ããšã«ãçãããããã³ãã¥ããã£ã«ç©æ¥µçã«è²¢ç®ããŸãããã