ã¯ããã«
ãååã§ã¯ãããã¼å¶å¾¡ã®ã¡ã½ããã使ç¨ãã¦ã¢ã¯ã·ã§ã³ããURLãé·ç§»ãããã¨ãªãå¥ã¢ã¯ã·ã§ã³ãå¼ã³åºãæ¹æ³ãããã¦ãªãã¤ã¬ã¯ããè¡ãæ¹æ³ãç´¹ä»ãã¾ãããããã§ã³ã³ããã¼ã©ã«é¢ãã主è¦ãªæ©è½ã«ã¤ãã¦ã®ç´¹ä»ãçµãã¦ãä»åããã¯ã¢ãã«ã«ç§»ã£ã¦ããããã¨æãã¾ãã
ãã¨ããã§ãCatalystã®5.7ãã5.8ã«ãã¼ã¸ã§ã³ã¢ãããããéã«ãå é¨ãå®è£ ããä»çµã¿ã¨ãã¦Mooseãæ¡ç¨ããã¾ãããMooseã¨ã¯Perl5ã«ãªãã¸ã§ã¯ãã·ã¹ãã ãå°å ¥ããããã®ã¢ã¸ã¥ã¼ã«ã§ãããããã¾ã§ã®blessã使ç¨ããPerlã®ãªãã¸ã§ã¯ãæåããã°ã©ãã³ã°ãããç°¡åã«ãããå¤ãã®ãã¨ãå®ç¾ã§ãã¾ãã
ãæ¬è¨äºã§ã¯ãç°¡åã«ã§ã¯ããã¾ããblessã¨Mooseãæ¯è¼ããPerlã®ãªãã¸ã§ã¯ãæåããã°ã©ãã³ã°ã«ã¤ãã¦èª¬æãããã®å¾ã§ã¢ãã«ã®æ¦è¦ã説æãã¦ããã¾ãã
対象èªè
- Perlã§ç°¡åãªã¹ã¯ãªãããä½æãããã¨ã®ããæ¹
- Perlã®ãªãã¸ã§ã¯ãæåããã°ã©ãã³ã°ã«ã¤ãã¦åæ©çãªç¥èã®ããæ¹
- Webã¢ããªã±ã¼ã·ã§ã³ã®åºæ¬çãªä»çµã¿ï¼HTTPãªã¯ã¨ã¹ããã¬ã¹ãã³ã¹ãªã©ï¼ã«ã¤ãã¦ã®ç¥èã®ããæ¹
ããã¾ã§ã®é£è¼
- åãã¦ã®Catalystå ¥éï¼1ï¼ãPerlã«ããWebãã¬ã¼ã ã¯ã¼ã¯Catalystã¨ã¯ï¼
- åãã¦ã®Catalystå ¥éï¼2ï¼ãCatalystã¢ããªã¯ã©ã®ããã«ä½ãã®ãï¼
- åãã¦ã®Catalystå ¥éï¼3ï¼ãå¦çã®å ¥ãå£ã¯ã¢ã¯ã·ã§ã³
- åãã¦ã®Catalystå ¥éï¼4ï¼ãURLãã¹ã¨ãªã¯ã¨ã¹ããã©ã¡ã¼ã¿
- åãã¦ã®Catalystå ¥éï¼5ï¼ãããã¼å¶å¾¡ã¨Chainedã¢ã¯ã·ã§ã³
å¿ è¦ãªç°å¢
ãæ¬é£è¼ã§ç´¹ä»ãããµã³ãã«ãªã©ã§å®è¡ãã¦ããç°å¢ã¯æ¬¡ã®éãã§ãã
CentOS 5.3
- Perl 5.8.9
- Catalyst 5.80013
ãã¾ããåä½ç¢ºèªãè¡ã£ãWindowsã®ç°å¢ã¯æ¬¡ã®éãã§ãã
Windows Vista
- ActivePerl 5.8.9 Build 826
- Catalyst 5.80011
Perlã®ãªãã¸ã§ã¯ãæåããã°ã©ãã³ã°
ãPerl5ã¾ã§ã¯ãC++ãJavaã®ãããªãªãã¸ã§ã¯ãã¨ããæ¦å¿µã¯è¨èªä»æ§ã«ã¯å«ã¾ãã¦ããããè¨èªã®äºææ§ãä¿ã£ãã¾ã¾å®ç¾ããããã«ãå¾ä»ã¨ãã¦ç¬ç¹ãªä»çµã¿ãå®è£ ããã¾ããã
ããã®ç¬ç¹ãªä»çµã¿ã§ãªãã¸ã§ã¯ããä½æããããã«ã¯bless
é¢æ°ã使ç¨ãã¾ããPerlã®ãªãã¸ã§ã¯ãã¯ãªãã¡ã¬ã³ã¹ã§ãããpackage
ã§æå®ãããåå空éã¨ãªãã¡ã¬ã³ã¹ãçµã³ã¤ããã®ãbless
ã«ãªãã¾ãããªãã¸ã§ã¯ãã¯ãªãã¡ã¬ã³ã¹ã§ããã®ã§ãããããã£ãã¡ã½ããã«ã¯->
æ¼ç®åã使ç¨ãã¦ã¢ã¯ã»ã¹ãã¾ãã
ãFoo
ãªãã¸ã§ã¯ããçæããbar
ã¡ã½ãããå¼ã³åºãå ´åã«ã¯æ¬¡ã®ããã«è¨è¿°ãã¾ãããªãã¸ã§ã¯ãã®çæãè¡ãã¡ã½ããåï¼ã³ã³ã¹ãã©ã¯ã¿ï¼ã«ã¯ã©ã®ãããªååã使ç¨ãã¦ããã¾ãã¾ããããnew
ã¨ããååãæ
£ä¾ã¨ãã¦ä½¿ããã¦ãã¾ãã
# Fooãªãã¸ã§ã¯ãã®çæ my $foo = Foo->new(); # barã¡ã½ããã®å¼ã³åºã $foo->bar();
ãbless
ã§ã¯ãåå空éã¨ãªãã¡ã¬ã³ã¹ã¨ã®é¢é£ã¥ããè¡ãã¨ããã¾ã§ããé¢åãè¦ã¦ãããªããããã³ã³ã¹ãã©ã¯ã¿ãããããã£ã¸ã®ã¢ã¯ã»ã¹ã¡ã½ãããããã«èªã¿åãå°ç¨ãªã©ã®ã¢ã¯ã»ã¹æ¨©éã¾ã§ãå«ãã¦ããã°ã©ãããã¡ãã¡è¨è¿°ããå¿
è¦ãããã¾ãããããã®å¦çã¯ã»ã¨ãã©åãå½¢å¼ã®ããããªãã¸ã§ã¯ããå¢ããã°ããã ããä¼¼ããããªã¡ã½ããã延ã
ã¨æ¸ãç¶ãããã¨ã«ãªãã¾ãã
ããã®ãããªãåããã¨ã®ç¹°ãè¿ããé¿ããããã«ãPerlã§ã¯ã¢ã¸ã¥ã¼ã«ã¨ããå½¢ã§ãã¾ãã¾ãªã¯ã©ã¹ã®å®ç¾©ææ³ãææ¡ããã¦ãã¾ããã
ãCPANã«ã¯ãClass::
ã§å§ã¾ããã¾ãã¾ãªã¯ã©ã¹å®ç¾©ã¢ã¸ã¥ã¼ã«ãç»é²ããã¦ãããããããã«ç¹å¾´ãæã£ãæ©è½ãç¨æãã¦ãã¾ãããããã®è©¦ã¿ã®ãªããããã¡ã¿ãªãã¸ã§ã¯ããããã³ã«ï¼Meta Object Protocolï¼MOPï¼ãå©ç¨ããMooseãç»å ´ãã¾ãããMoose
ã使ç¨ãããã¨ã§ããªãã¸ã§ã¯ãæåããã°ã©ãã³ã°ãããä¸ã§ã®ç
©éãªæç¶ãããããç°¡åã«è¡ããã¨ãã§ããããã«ãªãã¾ãã
ã以éã§ã¯ãPerson
ã¯ã©ã¹ã¨ãããç¶æ¿ããBaseballPlayer
ã¯ã©ã¹ãä¾ã¨ãã¦ãbless
ã¨Moose
ã§ã©ã®ããã«ã¯ã©ã¹ãå®ç¾©ããããç´¹ä»ãã¾ããPerson
ã«ã¯name
ã¨age
ã®2ã¤ã®ããããã£ãæã¡ãage
ã¯æ¸ãè¾¼ã¿ä¸å¯ã¨ãã¾ããBaseballPlayer
ã«ã¯team
ããããã£ã追å ããããããã®ã¯ã©ã¹ã«ã¯èªå·±ç´¹ä»ãè¡ãintroduce
ã¡ã½ãããå®ç¾©ãã¾ãã
ãã¡ã¿ãªãã¸ã§ã¯ããããã³ã«ã¨ã¯ããªãã¸ã§ã¯ãã·ã¹ãã ã«å¯¾ããæä½ãè¡ãããã®APIã§ãæ´¾çé¢ä¿ãªã©ã®ã¯ã©ã¹æ å ±ãåå¾ãããï¼ã¤ã³ããã¹ãã¯ã·ã§ã³ï¼ãã¯ã©ã¹ããªãã¸ã§ã¯ãã®æ¯ãèããå¤æ´ããï¼ã¤ã³ã¿ã¼ã»ãã·ã§ã³ï¼APIãæã¡ã¾ãã
ãPerl5ã®ãªãã¸ã§ã¯ãã·ã¹ãã ã«å¯¾ããMOPã®ã©ã¤ãã©ãªã¨ãã¦ã¯ãClass::MOPãæåã§ãMoose
ããã®Class::MOP
ã«å¯¾ããã©ããã¨ãã¦å®è£
ããã¦ãã¾ãã