ããã°ã©ãã³ã°ã®äžçã¯æ¥ã é²åãéããŠãããChatGPTãšPerlãçµã¿åãããéçºã泚ç®ãããŠããŸããPerlã®åŒ·åãªããã¹ãåŠçèœåãçãããChatGPTãšé£åããããšã§ãç¬èªã®ã¢ããªã±ãŒã·ã§ã³ãåµåºããå¯èœæ§ãåºãã£ãŠããŸãããã®èšäºã§ã¯ãããžãã¹ããŒãœã³ãPerlãçšããŠChatGPTãšã©ã®ããã«é£æºãããæ¥åå¹çåãžç¹ããããåŠã³ãŸããPerlããã°ã©ãã³ã°ãšChatGPTã®çµã¿åãããéããŠãããã¹ãåŠçãAPIã®æŽ»çšæ¹æ³ãã¯ãããå®è·µçãªã¹ã¯ãªããäŸãŸã§ãå¹ åºãç¥èã身ã«ã€ããŠããã ããã§ãããã
1. ChatGPT Perl ããã°ã©ãã³ã°ã®é å
Perlã¯é·ãéãå€ãã®éçºè ã«æãããŠããããã°ã©ãã³ã°èšèªã§ãããã®å¿çšæ§ã®é«ãããããŠããã¹ãåŠçã«é·ããæ©èœã¯ãããã°ã©ãã³ã°ã®é åã§å€å€§ãªåœ±é¿ãåãŒããŠããŸããChatGPTã®é²åãšåãããŠãPerlããã°ã©ãã³ã°ã¯ããã«æ°ããå°å¹³ãéæããŠããŸãã
ãã®èšäºã§ã¯ãPerlã®ããã°ã©ãã³ã°ã®äžçãžã®å ¥ãå£ããæ¡å ãããããChatGPTã®æè¡ãšã©ã®ããã«çµ±åããããããæ¢ç©¶ããŸãããŸããå®éã®ããã°ã©ã ã§ã®å¿çšäŸã玹ä»ããPerlã®é åãäœãããšãªããäŒãããããšãç®æããŸãã
PerlãšChatGPTã®çµã¿åãããæäŸããç¡éã®å¯èœæ§ã«ã€ããŠäžç·ã«æ¢ãæ ãå§ããŸãããã
1.1 Perlã®ããã°ã©ãã³ã°ç°å¢ãšç¹åŸŽ
Perlã¯ãã·ã³ãã«ãªã¹ã¯ãªããèšèªããè€éãªã¢ããªã±ãŒã·ã§ã³éçºãŸã§å¹ åºãçšéã«å¯Ÿå¿ããèšèªã§ããç¬èªã®æ§æã«ãããéçºè ã¯æ¯èŒçå°ãªãã³ãŒãã§å€æ§ãªæ©èœãå®è£ ã§ããŸãããã®æè»æ§ãPerlãç¹ã«åŒ·åãªããŒã«ãžãšå€ããŠããã®ã§ãã
Perlã®ç°å¢èšå®ã¯ãã»ãšãã©ã®ãªãã¬ãŒãã£ã³ã°ã·ã¹ãã ã§ç°¡åã«è¡ããè±å¯ãªã¢ãžã¥ãŒã«ã®ãµããŒãã«ããéçºã®å¹ ãåºãããŸããCPANïŒComprehensive Perl Archive NetworkïŒã¯ãåå©çšå¯èœãªPerlãœãããŠã§ã¢ã®ã©ã€ãã©ãªã§ãããéçºè ãå¿ èŠãªã¢ãžã¥ãŒã«ãæ¢ããããããŠããŸãã
å ããŠãPerlã¯æ£èŠè¡šçŸã®ãµããŒããéåžžã«å å®ããŠããããã¿ãŒã³ãããã³ã°ãããã¹ãåŠçã«ãããŠä»ã®èšèªã«æ¯ã¹ãŠåªããŠãããšãããŠããŸãããã®ç¹åŸŽã¯ãåŸã«çŽ¹ä»ããChatGPTãšã®é£æºã«ãããŠã倧ããªã¢ããã³ããŒãžãšãªã£ãŠããŸãã
1.2 ChatGPTãšPerlã®èå
ChatGPTã¯ãèªç¶èšèªåŠçã«ãããŠãã®èœåãçºæ®ãã人工ç¥èœãã¯ãããžãŒã§ããPerlãšçµã¿åãããããšã§ããã®ããã¹ã解æèœåãšPerlã®ããã¹ãæäœèœåãåæã«å©çšããããšãã§ããŸããChatbotsãèªååãããã«ã¹ã¿ããŒãµããŒãã·ã¹ãã çãå€ãã®ã¢ããªã±ãŒã·ã§ã³ã§ãã®çµã¿åãããæå¹ã§ãã
ChatGPTã«ã¯ããŠãŒã¶ãŒã®åãããã«å¯ŸããŠé©åãªã¬ã¹ãã³ã¹ãçæããèœåããããŸãããPerlã䜿ã£ãŠãã®ã¬ã¹ãã³ã¹ãå å·¥ããããã«æŽç·Žãããã¢ãŠãããããçã¿åºããŸãããã£ãããããã®å¿çæ§èœãé«ããããã«ãPerlã®ãã¯ãã«ãªæ£èŠè¡šçŸãšçµ±åããããšãäžã€ã®éµã«ãªããŸãã
ããã«ããªãŒãã³ãœãŒã¹ã³ãã¥ããã£ã«ããç¶ç¶çãªéçºã§ãPerlãšChatGPTã®èåã¯åžžã«æ°ãããªããããéçºè ã¯åžžã«ææ°ã®æ©èœã掻çšããããšãã§ããŸãããã®æè»æ§ããPerlãšChatGPTã®è¯ãã·ããžãŒãçã¿åºããŠããŸãã
1.3 Perlã§ã®ããã¹ãåŠçã®åŒ·åãªæ©èœ
Perlã¯ãããã¹ãåŠçã®ã¹ã€ã¹ã¢ãŒããŒãã€ãããšãè¡šçŸãããŸãã匷åãªããã¹ãåŠçã®èœåã¯ãã¬ããŒãçæãããŒã¿æœåºãã·ã¹ãã 管çã¿ã¹ã¯çãããããå Žé¢ã§ãã®äŸ¡å€ãçºæ®ããŸããå šæãèªåšã«æ±ãããšãå¯èœãªPerlã®ãã¿ãŒã³ãããã³ã°ã¯ãéçºè ã®éã§é«ãè©äŸ¡ãããŠããŸãã
ç·šéäœæ¥ãèªååããè€éãªãã°ãã¡ã€ã«ãããŒã¿ã»ããããæçãªæ å ±ãæœåºããéã«Perlã¯å€§ããªåãšãªããŸããPerlã®æ£èŠè¡šçŸã¯åçŽãªæåå眮æãããè€éãªãã¿ãŒã³ãããã³ã°ãŸã§éåžžã«é«ãæ©èœãæäŸããŸãã
ããã«ãPerlã¯éåžžã«æ©ãå®è¡ããããšãã§ããããã倧éã®ããŒã¿ãåŠçããéã«ãé«ãããã©ãŒãã³ã¹ãç¶æããŸãããã®åŠçé床ãšçµã¿åãããããšã§ãPerlã¯ããŒã¿è§£æãšããã¹ãåŠçã®é åã§éå®ãããçç±ããããŸãã
1.4 ChatGPTãçšããPerlããã°ã©ã ã®å¿çšäŸ
ChatGPTãçšããPerlããã°ã©ã ã¯é©æ°çãªå¿çšãå¯èœã§ããäŸãã°ã顧客ããã®ãã£ãŒãããã¯ãèªå解æããããã«åºã¥ãçµ±èšã¬ããŒãããµããªãŒãçæããã·ã¹ãã ã¯ãããžãã¹ã§ã®ææ決å®ã«åœ¹ç«ã¡ãŸããããã¯Perlã®ããã¹ãåŠçèœåãšChatGPTã®èšèªç解èœåãçµã¿åããããã®ã§ãã
æŽã«ããœãŒã·ã£ã«ã¡ãã£ã¢äžã®ãã¬ã³ããåæããèªåã§ã³ã³ãã³ããçæããããŒã«ãèããããŸããããã«ããããŒã±ãã£ã³ã°æŠç¥ã«è¿ éã«å¯Ÿå¿ããããšãå¯èœãšãªããŸãããããã¯ãå é²çãªããã¹ãã¢ããªãã£ã¯ã¹ã«PerlãšChatGPTã掻çšããå¿çšäŸã®äžéšã«éããŸããã
ãã«ããã¹ã¯ããµããŒããã±ããã®èªåè¿çã·ã¹ãã ãæ§ç¯ããããšã§ããçµç¹ã®å¹çåã«è²¢ç®ã§ããŸãããããã®äŸãã䌺ããéããPerlãšChatGPTã®çµã¿åããã¯ãå€ãã®æ¥çã§å¹æçãªãœãªã¥ãŒã·ã§ã³ãæäŸã§ããã ãã§ãªããå°æ¥ã®ããŒãºã«ãæè»ã«å¯Ÿå¿ããããšãã§ããŸãã
2. å§ãããïŒChatGPTã䜿ã£ãPerlããã°ã©ãã³ã°
Perlããã°ã©ãã³ã°ã¯ãããã¹ãåŠçã«åªããæ±çšããã°ã©ãã³ã°èšèªã§ãããå€ãã®ã·ã¹ãã 管çè ããŠã§ãéçºè ã«æçšãããŠããŸããChatGPTãšå ±ã«PerlãåŠã¶ããšã§ãããã°ã©ãã³ã°ã®ç解ãããã«æ·±ããããšãã§ããã§ãããããã®èšäºã§ã¯ãPerlã®åºç€ããChatbotã®äœæãŸã§ã解説ããŠãããŸãã
2.1 Perlã®åºæ¬çãªææ³ãšæ§é
Perlã¯ãCèšèªã«äŒŒãã·ã³ã¿ãã¯ã¹ãæã¡ãæè»ãªèšèªæ§é ãæããŠããŸããå€æ°ã®åã«ç¹å®ã®ã·ã³ãã«ãä»ããããšã§ãã¹ã«ã©ãŒãé åãããã·ã¥ãšãã£ãç°ãªãããŒã¿åãæ±ããã®ãç¹åŸŽã§ãã
ã¹ã«ã©ãŒå€æ°ã¯ãã«èšå·ïŒ$ïŒã§å§ãŸããåäžã®å€ãæ±ããŸããé åå€æ°ã¯ã¢ããããŒã¯ïŒ@ïŒã§å§ãŸãäžé£ã®å€ãæ ŒçŽããããã·ã¥å€æ°ã¯ããŒã»ã³ãèšå·ïŒ%ïŒã§å§ãŸããããŒãšå€ã®ãã¢ãæ±ããŸããæ¡ä»¶åå²ãã«ãŒãåŠçãCèšèªã«äŒŒãŠãããifæãwhileæãforæãçšããããŸãã
ãµãã«ãŒãã³ã¯åå©çšå¯èœãªã³ãŒãã®ãããã¯ãäœæããæ段ã§ãããã¢ãžã¥ãŒã«ã䜿çšããŠã³ãŒãã®åå©çšæ§ãé«ããŸããæ£èŠè¡šçŸãPerlã®åŒ·åãªæ©èœã®äžã€ã§ãããã¹ãã®ãã¿ãŒã³ãããã³ã°ãå å·¥ãç°¡æœã«èšè¿°ã§ããŸãã
2.2 ChatGPTã§ããã°ã©ãã³ã°ãåŠã¶ã¡ãªãã
ChatGPTã¯ãèªç¶èšèªãç解ããæ©èœãæã€AIã§ããChatGPTã䜿ã£ãŠPerlãåŠã¶æ倧ã®ã¡ãªããã¯ãçŽæçãªäŒè©±åœ¢åŒã§ããã°ã©ãã³ã°ã®æŠå¿µãæ¢æ±ã§ããããšã«ãããŸãã
åå¿è ãææ³ãæ§é ã«çåãæã£ããšãããªã¢ã«ã¿ã€ã ã§æå¿«ãªè§£èª¬ãåŸãããšãã§ããŸãããŸããäŸç€ºãã³ãŒãä¿®æ£ãéããŠå ·äœçãªã¢ããã€ã¹ããããããšãå¯èœã§ãã
ããã«ãæ¢åã®ã³ãŒãã®åé¡ç¹ãææããŠããã£ãããæ°ããããã°ã©ã ãäžç·ã«èããéçšã§ãæ·±ãæŽå¯åãåé¡è§£æ±ºèœåãé€ãããšãã§ããŸãã
2.3 ç°¡åãªChatbotã®äœææ¹æ³
åºæ¬çãªPerlã®ææ³ãç解ããããç°¡åãªChatbotãäœãããšã次ã®ã¹ãããã§ããæåã«ãå ¥åãåãåããããã«å¿ããåºåãè¿ãæãåºæ¬çãªæ çµã¿ããå§ããŸãããã
ã¹ã¯ãªããã§ã¯ãæšæºå ¥åããããã¹ããåãåããããã«å¿ããŠããã°ã©ã å ã§å®çŸ©ããã«ãŒã«ã«åºã¥ããŠã¬ã¹ãã³ã¹ãçæããŸããäŸãã°ãæšæ¶ã«å¯Ÿããå¿çãç¹å®ã®ããŒã¯ãŒãã«å¯Ÿããåçãå®çŸ©ããããšãã§ããŸãã
ãã®ãããªããããäœãéã«ã¯ãæ£èŠè¡šçŸã掻çšããããŸããŸãªå ¥åã«å¯ŸããŠæè»ã«å¯Ÿå¿ã§ããããã«ããŸãããŸãããŠãŒã¶ãŒã€ã³ã¿ãŒãã§ãŒã¹ãã·ã³ãã«ãªã³ãã³ãã©ã€ã³ããããŠã§ãã€ã³ã¿ãŒãã§ãŒã¹ãæã€ãã®ãŸã§ãå¿çšã®ç¯å²ã¯åºãããŸãã
2.4 ãããã°ãšãšã©ãŒåŠçã®ãã¯ããã¯
ããã°ã©ãã³ã°ã«ãããŠãããã°ã¯äžå¯æ¬ ãªäœæ¥ã§ããPerlã§ã¯ãèŠåãæå¹ã«ããŠããã°ã©ã ãå®è¡ããããšã§ãæœåšçãªåé¡ãæ©æã«çºèŠã§ããŸããããã¯ãuse warnings; åœä»€ã䜿ãããšã§å®çŸã§ããŸãã
ãšã©ãŒã¡ãã»ãŒãžãç解ããåé¡ãçºçããå Žæãšãã®åå ãç¹å®ããããšãéèŠã§ãããŸããuse strict; åœä»€ãçšããŠå³æ Œãªã³ãŒãã£ã³ã°èŠåãé©çšããããšã§ãå€æ°å®£èšã®æŒããã¿ã€ããã¹ãé²ãããšãã§ããŸãã
倧èŠæš¡ãªããã°ã©ã ã§ã¯ããããã°ã¢ãžã¥ãŒã«ããããã¡ã€ã©ã䜿çšããŠããã©ãŒãã³ã¹ã®ç£èŠãšæé©åãè¡ãæ¹ãå¹ççãã€å¹æçã§ããCPANãªã©ã®ãªãœãŒã¹ãã䟿å©ãªããŒã«ãèŠã€ããŠããããã°ããã»ã¹ã«çµã¿èŸŒãããšãæšå¥šãããŸãã
3. Perlã§ChatGPT APIã掻çšããæ¹æ³
3.1 ChatGPT APIãšã¯
ChatGPT APIã¯ãèªç¶èšèªåŠçãã¿ã¹ã¯ã«æŽ»çšããããã®åŒ·åãªããŒã«ã§ãããããå©çšããããšã§ããŠãŒã¶ãŒã¯ç¬èªã®ããã°ã©ã ãã¢ããªã±ãŒã·ã§ã³å ã§ChatGPTã®èœåã䜿ã£ãŠãããã¹ãã®çæã解æãè¡ãããšãã§ããŸããAPIã¯åºæ¬çã«ã¢ããªã±ãŒã·ã§ã³ããã°ã©ãã³ã°ã€ã³ã¿ãŒãã§ãŒã¹ã®ç¥ã§ããœãããŠã§ã¢éã§ã®äŒè©±ãå¯èœã«ããäžçš®ã®æ©æž¡ãã®åœ¹å²ãæãããŠããŸãã
äžè¬ã«ãAPIãå©çšããéã«ã¯APIããŒãå¿ èŠãšãªããããã¯äœ¿çšè ãæ£åœãªç®çã§APIã䜿çšããããã®ãã®ã§ããAPIããŒãšãšã³ããã€ã³ãã䜿çšããŠãChatGPTãšã®éä¿¡ã確ç«ãããŸãããã®éä¿¡ã«ããããŠãŒã¶ãŒãéçºããã¢ããªã±ãŒã·ã§ã³ã¯ãChatGPTã®ç¥èãšèªåŠèœåãå©çšã§ããããã§ãã
éçºè ã¯ãChatGPT APIã䜿ãããªãããšã§ãããããããã¹ãããŒã¹ã®ã¿ã¹ã¯ãèªååãããããŠãŒã¶ãŒã€ã³ã¿ãã§ãŒã¹ãåäžããããããããšãæåŸ ã§ããŸããç¹ã«ãã«ã¹ã¿ããŒãµãŒãã¹ãã³ã³ãã³ãçæãããã«ã¯æè²çãªçšéãªã©ãåºç¯å²ã«ãããçšéã§åœ¹ç«ã¡ãŸãã
3.2 Perlã§ã®APIæ¥ç¶ã®åºæ¬
Perlã§ChatGPT APIã«æ¥ç¶ããããã«ã¯ãHTTPãªã¯ãšã¹ãã䜿ãã®ãäžè¬çã§ããPerlã«ã¯CPANãªã©ã®ãªããžããªã«å€æ°ã®HTTPã¯ã©ã€ã¢ã³ãã©ã€ãã©ãªããããŸããããã®äžã§ããLWP::UserAgentãã¯éåžžã«ããã¥ã©ãŒãªéžæè¢ã§ããLWP::UserAgentã䜿ã£ãŠããšã³ããã€ã³ãã«GETãPOSTãªã¯ãšã¹ããéä¿¡ããããšã«ããAPIãšã®éä¿¡ãè¡ãããŸãã
APIã«ã¢ã¯ã»ã¹ããéããŸãã¯APIããŒã®èšå®ãå¿ èŠã«ãªããŸãããã®ããŒããªã¯ãšã¹ãã®ããããŒã«å«ããããšã§ãAPIãµãŒããŒã«å¯ŸããŠèªèšŒãè¡ããå©çšèš±å¯ãåŸãããšãã§ããŸããPerlã§ã®ããããŒèšå®ã¯ã¢ãžã¥ãŒã«ã䜿ã£ãŠç°¡åã«è¡ãããšãã§ããå¿ èŠãªãã©ã¡ãŒã¿ãããŒã¿ãšå ±ã«APIãžãªã¯ãšã¹ããè¡ããŸãã
ã³ãŒãã®åºæ¬çãªæ§é ã¯ãLWP::UserAgentãªããžã§ã¯ããäœæããé©åãªHTTPã¡ãœãããéžæããŠæ å ±ãéä¿¡ãããšãããã®ã§ããå¿çãè¿ã£ãŠããããå 容ã粟æ»ãå¿ èŠã«å¿ããŠåŠçãè¡ããŸããPerlã®flexibleãªæåååŠçèœåã¯ãå¿çããŒã¿ã®ããŒã¹ãæäœã«ç¹ã«æå¹ã§ãã
3.3 APIå¿çã®åŠçãšå©çšæ¹æ³
ChatGPT APIããã®å¿çã¯éåžžJSON圢åŒã§è¿ã£ãŠããŸããPerlã§ã¯ãJSONããŒã¿ã®è§£æãšæ±ãã容æã«ããããã®ã¢ãžã¥ãŒã«ãçšæãããŠããŸããç¹ã«ãJSONãã¢ãžã¥ãŒã«ã䜿çšããããšã§ãåŸãããããŒã¿ãPerlã®ããŒã¿æ§é ã«ãã³ãŒãããæ±ãããã圢ã«å€æããããšãå¯èœã§ãã
JSONããŒã¿ãæ±ã£ãåŸãAPIããåŸãããæ å ±ãåºã«å¿ èŠãªã¢ã¯ã·ã§ã³ãå®è¡ããŸããäŸãã°ããã£ããããããäœæããå ŽåãAPIããã®å¿çãããŒã¹ããŠãŠãŒã¶ãŒãžã®ã¬ã¹ãã³ã¹ãšããŠåºåããããšã«ãªããŸãããã®ä»ã«ããåãåã£ãæ å ±ãããŒã¿ããŒã¹ã«ä¿åããããŸãã¯ä»ã®ã·ã¹ãã ãšã®é£æºãè¡ããªã©ã®åŠçãå ããããšãã§ããŸãã
éèŠãªã®ã¯ãå¿çããŒã¿ãé©åã«ãšã©ãŒãã³ããªã³ã°ããå¿ èŠãªæ å ±ã®ã¿ãæœåºããããšã§ããPerlã®åŒ·åãªæ£èŠè¡šçŸãããŒã¿æ§é 管çæ©èœã掻çšããããšã§ãAPIããåŸããã倧éã®æ å ±ããå¿ èŠãªããŒã¿ãå¹ççã«åãåºãããšãã§ããŸãã
3.4 ã»ãã¥ãªãã£é¢ã§ã®æ³šæç¹ãšãã¹ããã©ã¯ãã£ã¹
APIãå®å šã«å©çšããã«ã¯ãã»ãã¥ãªãã£é¢ã§ã®é æ ®ãå¿ èŠäžå¯æ¬ ã§ããç¹ã«APIããŒã¯æ éã«ç®¡çããå ¬éãããã¹ãã§ã¯ãããŸãããPerlã¹ã¯ãªãããGitHubãªã©ã®å ¬éãªããžããªã«ã¢ããããŒãããå Žåã«ã¯ç¹ã«æ³šæãå¿ èŠã§ãAPIããŒãç°å¢å€æ°ãèšå®ãã¡ã€ã«ã«æ ŒçŽããããšã§ãäžæ£ã¢ã¯ã»ã¹ããå®ãããšãã§ããŸãã
å ããŠãéä¿¡æã®ã»ãã¥ãªãã£ãéèŠã§ããHTTPSãããã³ã«ãéããŠæå·åãããéä¿¡ãè¡ãããšã§ãäžéè æ»æãªã©ã«ããããŒã¿ã®çèŽãæ¹ãããé²ãããšãã§ããŸããPerlã®HTTPã¯ã©ã€ã¢ã³ãã©ã€ãã©ãªã¯äžè¬çã«æå·åéä¿¡ããµããŒãããŠããŸãããèšå®ã確èªããé©åã«é©çšããããšãéèŠã§ãã
ãŸããçŠæ¢ãããŠããå©çšãé床ãªãªã¯ãšã¹ãã§APIã®å©çšãåæ¢ãããªããããAPIã®å©çšèŠçŽããªã¯ãšã¹ãå¶éãç解ãéµå®ããããšãèå¿ã§ããPerlã®ã¹ã¯ãªãããäœæããéã«ã¯ãAPIãžã®ã¢ã¯ã»ã¹ã«ã¿ã€ã ã¢ãŠãèšå®ããããããšã©ãŒã¬ã¹ãã³ã¹ãé©åã«ãã³ããªã³ã°ãããªã©ã®ãã¹ããã©ã¯ãã£ã¹ãå®è·µããŸãããã
4. å®è·µïŒChatGPTã掻çšããPerlã¹ã¯ãªããäŸ
4.1 ç°¡åãªäŒè©±ã¢ããªã±ãŒã·ã§ã³ã®äœæ
PerlãçšããäŒè©±ã¢ããªã±ãŒã·ã§ã³ã®éçºã¯ãããã¹ãããŒã¹ã®ã·ã³ãã«ãªå¯Ÿè©±ã·ã¹ãã ããå§ããããšãã§ããŸããæ¬çš¿ã§ã¯ãåºæ¬çãªå ¥åãšå¿çæ©èœãæã€ãã£ããã¢ããªã±ãŒã·ã§ã³ã®æ§ç¯æé ã説æããŸããPerlã®åŒ·åãªããã¹ãåŠçèœåã掻çšããŠããŠãŒã¶ãŒã®è³ªåã«å¯ŸããŠå®åçãªè¿çãçæãããµã³ãã«ã¢ããªã±ãŒã·ã§ã³ãäœããŸãããã
å§ãã«ãCPANããå ¥æã§ããåçš®ã¢ãžã¥ãŒã«ãå©çšããŠãéçºæéãšåŽåãç¯çŽããŸããäŸãã°ãHTTPãªã¯ãšã¹ãã®åŠçãå©ããLWP::UserAgentããJSONããŒã¿ã®ããŒã¹ã«äŸ¿å©ãªJSONã¢ãžã¥ãŒã«ããããŸãããããã䜿çšããã¢ããªã±ãŒã·ã§ã³ãChatGPT APIãšéä¿¡ããéã«å¿ èŠãªåèœãç°¡åã«å®è£ ããããšãå¯èœã§ãã
ã³ãŒãã®äž»äœã¯ãå ¥åãåãåãããããChatGPT APIã«éä¿¡ããããšããæãç«ã£ãŠããŸããAPIããã®å¿çããŠãŒã¶ãŒã«è¡šç€ºããæ§é ãšãªããŸãããŠãŒã¶ãŒããã®å ¥åãããŸãåŠçããæåŸ ããå¿çãè¿ã£ãŠããããã«ãå ¥åºååŠçã«ã¯çŽ°å¿ã®æ³šæãå¿ èŠã§ãããã®æ®µéã§ã¯ãç°¡åã«ã«ã¹ã¿ãã€ãºã§ããããšãPerlã®å€§ããªå©ç¹ã§ãã
4.2 ããŒã¿è§£æãšã¬ããŒãçæ
Perlã¯å€ãããããŒã¿è§£æãšã¬ããŒãçæã«äœ¿çšãããŠããŸãããç¹ã«ããã°ãã¡ã€ã«ãCSVããŒã¿ãªã©ã®æ§é åãããŠããªãããŒã¿ã»ãããæ±ãéã«ãã®ç䟡ãçºæ®ããŸããPerlã®ããã¹ãåŠçã®èœåãå©çšããŠãè€éãªããŒã¿ãã¿ãŒã³ã®æ€çŽ¢ã眮æãéèšãè¡ãã¹ã¯ãªãããç°¡åã«èšè¿°ããããšãå¯èœã§ãã
æ£èŠè¡šçŸã䜿çšããããŒã¿ã®æœåºã¯Perlã®åŸæãšããé åã§ãããåçš®ãã°ãã¡ã€ã«ããç¹å®ã®æ å ±ãåãåºããŠåæããã¹ã¯ãªãããç°¡åã«äœæã§ããŸãããŸããDBIã¢ãžã¥ãŒã«ã䜿çšããããšã§ãããŒã¿ããŒã¹ã«æ ŒçŽãããŠããæ å ±ã®ååŸãæäœãè¡ãããšãã§ããŸãã
ã¬ããŒãã®åœ¢åŒã¯ããã¹ãã®ã¿ãªãããHTMLãExcelãã¡ã€ã«ãšããŠåºåããããšãå¯èœã§ããããã«ãããããŒã¿ãèŠèŠçã«ãããããããŸãšããããããã«åæãããã圢ã«å å·¥ããããšãã§ããŸããPerlã¯ããŒã¿è§£æã®ãããŒãèªååããæ¥ã ã®æ¥åãå¹çåããããã®åŒ·åãªããŒã«ãšãªãã§ãããã
4.3 Webã¹ã¯ã¬ã€ãã³ã°ãšæ å ±ã®èªååé
Webã¹ã¯ã¬ã€ãã³ã°ã¯ãWebããŒãžããå¿ èŠãªæ å ±ãæœåºããèªåçã«åéããææ³ã§ããPerlã«ã¯Webã¹ã¯ã¬ã€ãã³ã°ãæ¯æŽããè±å¯ãªã©ã€ãã©ãªããããå¹ççã«æ å ±ãåéããããšãå¯èœã§ããäŸãã°ãWWW::Mechanizeã¢ãžã¥ãŒã«ãWeb::Queryã¢ãžã¥ãŒã«ã䜿çšããããšã§ããŠã§ããµã€ããèªåçã«ããã²ãŒãããå¿ èŠãªããŒã¿ãæœåºã§ããŸãã
質ã®é«ãã¹ã¯ã¬ã€ãã³ã°ã¹ã¯ãªãããäœæããã«ã¯ã察象ã®WebããŒãžã®DOMæ§é ãææ¡ããé©åãªHTMLèŠçŽ ãæå®ããå¿ èŠããããŸããPerlã®ã©ã€ãã©ãªãå©çšããã°ãCSSã»ã¬ã¯ã¿ãXPathã䜿ã£ãŠç¹å®ã®èŠçŽ ãç°¡åã«èŠã€ããããšãã§ããŸãããŸãããã©ãŒã ã®éä¿¡ããã°ã€ã³åŠçãèªååããããšã§ãããè€éãªã¹ã¯ã¬ã€ãã³ã°ãå®çŸããããšãã§ããŸãã
åéããããŒã¿ã¯ãåæã®ããã«ããŒã¿ããŒã¹ãžä¿åããããããŸããŸãªãã©ãŒãããã«å€æããŠåºåããããšãã§ããŸããWebã¹ã¯ã¬ã€ãã³ã°ãéããŠãææ°ã®æ å ±ãå®æçã«ååŸããããžãã¹ã®ææ決å®ã«åœ¹ç«ã€ã€ã³ãµã€ããæäŸããããšãå¯èœã«ãªããŸãã
4.4 ã·ã¹ãã 管çãšèªååã®ããã®ã¹ã¯ãªããäŸ
Perlã¯ã·ã¹ãã 管çè ã«ãšã£ãŠåŒ·åãªèªååããŒã«ãšããŠã®å°äœã確ç«ããŠããŸãããµãŒããŒã®ç£èŠããã¡ã€ã«ã®ããã¯ã¢ããããã°ãã¡ã€ã«ã®åŠçãªã©ãæ¥åžžçãªã¿ã¹ã¯ãå¹çåããã¹ã¯ãªãããç°¡åã«äœæã§ããŸãããŸãããããã¯ãŒã¯ããã€ã¹ã®ç¶æ ç£èŠãæ§æå€æŽãªã©ãããå°éçãªçšéã«ã察å¿å¯èœã§ãã
äžäŸãšããŠãNet::SSH::Perlã¢ãžã¥ãŒã«ã䜿çšããã°ãPerlã¹ã¯ãªãããããªã¢ãŒãã®ãµãŒããŒã«å®å šã«SSHæ¥ç¶ããã³ãã³ããå®è¡ããããšãã§ããŸããããã«ãããè€æ°ã®ãµãŒããŒã«ãŸãããäžé£ã®ç®¡çã¿ã¹ã¯ãã1ã€ã®ã¹ã¯ãªããããã³ã³ãããŒã«ããããšãå¯èœã§ãã
ãŸãããã¡ã€ã«åŠçèœåãé§äœ¿ããŠãã·ã¹ãã ã®ç¶æ ãç£èŠããã¹ã¯ãªããããããã¯ããã©ãŒãã³ã¹ããŒã¿ãåéããåæãè¡ãã¹ã¯ãªãããäœæããããšãã§ããŸããPerlã®æè»æ§ãšåŒ·åãªæ©èœã»ããã«ãããã·ã¹ãã 管çè ã¯ã«ãŒãã³ã¯ãŒã¯ããéæŸãããããåµé çãªæ¥åã«éäžããããšãã§ããŸãã
ChatGPT Perl ããã°ã©ãã³ã°ã®ããã®ãªãœãŒã¹ãšã³ãã¥ããã£ã«ã€ããŠåŠã³ããæ¹ã¯å€ãã¯ãã§ããPerlã¯æè»ã§åŒ·åãªããã°ã©ãã³ã°èšèªã§ãããæ§ã ãªçšéã«æŽ»çšãããŠããŸããä»æ¥ã¯ãåå¿è ããäžçŽè ãŸã§ãäžäººäžäººãPerlã®äžçã«é£ã³èŸŒãããã«åœ¹ç«ã€ãªãœãŒã¹ãšã³ãã¥ããã£ã玹ä»ããŸãã
5. ChatGPT Perl ããã°ã©ãã³ã°ã®ããã®ãªãœãŒã¹ãšã³ãã¥ããã£
5.1 ãªã³ã©ã€ã³ããã¥ã¡ã³ããšãã¥ãŒããªã¢ã«ãžã®ã¢ã¯ã»ã¹
Perlã®åŠç¿ãå§ããã«ã¯ãé©åãªãªã³ã©ã€ã³ããã¥ã¡ã³ããšãã¥ãŒããªã¢ã«ãžã®ã¢ã¯ã»ã¹ãäžå¯æ¬ ã§ããCPANïŒComprehensive Perl Archive NetworkïŒã¯ãPerlã¢ãžã¥ãŒã«ãã¹ã¯ãªãããããã¥ã¡ã³ããè±å¯ã«æäŸããŠãããç¥èã®å¹ ãåºããã®ã«æé©ãªå Žæã§ãã
äž»èŠãªPerlãŠã§ããµã€ãã§ã¯ãåå¿è åãã®ã¬ã€ãããè€éãªãããã¯ãŸã§ãå¹ åºãæ å ±ãæŽçãããŠæäŸãããŠããŸãããŸãããperldocãã¯Perlã®å ¬åŒããã¥ã¡ã³ããŒã·ã§ã³ããŒã«ã§ãããã³ãã³ãã©ã€ã³ããçŽæ¥ã¢ã¯ã»ã¹ã§ãããããããã°ã©ãã³ã°äžã«ãªãã¡ã¬ã³ã¹æ å ±ãç°¡åã«åç §ã§ããŸãã
ããã«ãPerl MongersãPerl Weeklyãªã©ã®ãŠã§ããµã€ãã§ã¯ãææ°ã®ãã¬ã³ãããã¯ããã¯ã«é¢ããèšäºããã¥ãŒããªã¢ã«ãå®æçã«æäŸããŠãããPerlã³ãã¥ããã£ãšå¯æ¥ã«é£æºããŠããŸãã
5.2 ã³ãã¥ããã£ãšãã©ãŒã©ã ã§ãµããŒããåãã
Perlã³ãã¥ããã£ã¯äžçäžã«ç¹åšããŠãããå€ãã®ãã©ãŒã©ã ããªã³ã©ã€ã³ãã£ã¹ã«ãã·ã§ã³ã掻çºã«è¡ãããŠããŸããStack OverflowãPerlMonksã¯ãæè¡çãªçåãåé¡ã解決ããããã®çŽ æŽãããå Žæã§ããçµéšè±å¯ãªéçºè ããåå¿è ãŸã§åå ããŠããã®ã§ã質åãç¥èã®å ±æãããããã§ãã
IRCã®Perlãã£ã³ãã«ãã³ãã¥ãã±ãŒã·ã§ã³ã®ããã®ãªã¢ã«ã¿ã€ã ã®ãããšããŠäœ¿ãããŠãããçŽæ¥çãªãã£ãŒãããã¯ãã¢ããã€ã¹ãåŸãããããšãå€ãã§ãããã®ããã«ã€ã³ã¿ã©ã¯ãã£ããªã³ãã¥ããã£ã®äžå¡ã«ãªãããšã¯ãåé¡ãè¿ éã«è§£æ±ºããæ°ããã³ã³ã»ãããç解ããã®ã«åœ¹ç«ã¡ãŸãã
å ããŠãRedditãLinkedInãªã©ã®ãœãŒã·ã£ã«ã¡ãã£ã¢äžã«ãPerlé¢é£ã®ã°ã«ãŒããååšããããã°ã©ãå士ã®ãããã¯ãŒãã³ã°ã®å Žãšãªã£ãŠããŸããããããã°ã«ãŒããå©çšããŠé¢é£æ å ±ãåŸãããçµéšãå ±æããããšãå¯èœã§ãã
5.3 ãªãŒãã³ãœãŒã¹ãããžã§ã¯ããžã®è²¢ç®
Perlã䜿ã£ããªãŒãã³ãœãŒã¹ãããžã§ã¯ããžã®åå ã¯ãæ°ããªã¹ãã«ã磚ããå®åçµéšãåŸãããã®äžã€ã®æ段ã§ããGitHubãGitLabãªã©ã®ãã©ãããã©ãŒã ã¯Perlãããžã§ã¯ãããã¹ãããå€ãã®éçºè ãååããŠããŸãããããã®ãããžã§ã¯ãã«è²¢ç®ããããšã§ãå®éã®ã³ãŒãããŒã¹ãæäœãã貎éãªãã£ãŒãããã¯ãåŸãããŸãã
ãã°ã®å ±åãããã¥ã¡ã³ãã®æ¹åãæ°æ©èœã®éçºãªã©ãè²¢ç®ã®æ¹æ³ã¯æ§ã ã§ãããŸããã¡ã³ãããŒãä»ã®ã³ã³ããªãã¥ãŒã¿ãŒãšååããããšã§ãPerlã®ãã¹ããã©ã¯ãã£ã¹ã身ã«ä»ããããšãã§ãããããã§ãã·ã§ãã«ãªéçºè ã«è¿ã¥ãããšãã§ããŸãã
ãããŠPerlã®ã³ãã¥ããã£ã§ã¯ãå€ãã®å ŽåããªãŒãã³ãœãŒã¹ã®ç²Ÿç¥ãé«ãè©äŸ¡ããããããç©æ¥µçã«è²¢ç®ããããšã§ãã³ãã¥ããã£å ã§ã®è©å€ã人èãç¯ãããšãã§ããŸãã
5.4 ã€ãã³ããšããŒãã¢ããã§ãããã¯ãŒãã³ã°
Perlã®ã³ãã¥ããã£ã¯å®æçã«ã€ãã³ããããŒãã¢ãããéå¬ããŠãããPerlããã°ã©ããŒãã¡ãçŽæ¥é¡ãåãããæ©äŒãæäŸããŠããŸããYAPCïŒYet Another Perl ConferenceïŒãPerl Workshopãªã©ã®ã€ãã³ãã¯ãåŠã³ã亀æµããææ°ã®Perlã®ååã«è§Šããããšãã§ããçŽ æŽãããå Žã§ãã
ãããã®ã€ãã³ãã¯éåžžãè¬æŒãã¯ãŒã¯ã·ã§ãããããã«ãœã³ãç¹åŸŽãšããŠãããPerlã«ç±å¿ãªäººã ãéãŸããç¥èãã¢ã€ãã¢ãå ±æããŸããåå ããããšã§ãæ°ãããã¬ã³ããæè¡ããããŠãããžã§ã¯ãã«é¢ãã貎éãªæ å ±ãæã«å ¥ããããã ãã§ãªããä»äºã®æ©äŒãã³ã©ãã¬ãŒã·ã§ã³ã®æ©äŒã«ã€ãªããããšããããŸãã
å°å ã§éå¬ãããŠããå°èŠæš¡ãªPerlããŒãã¢ããããŠãŒã¶ãŒã°ã«ãŒãã«åå ããããšããã³ãã¥ããã£ãšç¹ããããã®è¯ãã¹ã¿ãŒãå°ç¹ãšãªããŸããå®æçã«éå¬ãããããããéãŸãã¯ãåãèå³ãæã€ä»²éãèŠã€ããæ å ±äº€æãè¡ãå ŽãšããŠçæ³çã§ãã
çµè«ãšããŠãChatGPT Perl ããã°ã©ãã³ã°ã®ãªãœãŒã¹ãšã³ãã¥ããã£ã¯è±å¯ã«ååšããŠãããéçºã®æ ã«ãããŠå€§ããªæ¯æŽãšãªããŸããäžèšã§çŽ¹ä»ããããã¥ã¡ã³ãããªã³ã©ã€ã³ãã©ãŒã©ã ããªãŒãã³ãœãŒã¹ãããžã§ã¯ããã€ãã³ããšãã£ããªãœãŒã¹ãæ倧é掻çšããŠãPerlã®ã¹ãã«ã磚ããç¥èŠãæ·±ãããããã¯ãŒã¯ãåºããŸãããã
6. ChatGPT Perl ããã°ã©ãã³ã°ã§ãããã質åãšåç
6.1 Perlã®ç°å¢èšå®ãšåæåé¡
Perlããã°ã©ãã³ã°ãå§ããã«åœãã£ãŠããç°å¢èšå®ã®æ¹æ³ã¯ïŒããšããçåãå€ãå¯ããããŸããéåžžã¯Perlã€ã³ã¿ãŒããªã¿ãå¿ èŠã§ãããå€ãã®UNIXç³»OSã«ã¯ãã§ã«ã€ã³ã¹ããŒã«ãããŠããŸãããWindowsã§ã¯Strawberry PerlãActivePerlãªã©ã®ãã£ã¹ããªãã¥ãŒã·ã§ã³ãã€ã³ã¹ããŒã«ããããšãæšå¥šãããŸãã
ãŸãåå¿è ãããééããåé¡ã®äžã€ã«ããã¢ãžã¥ãŒã«ã®ã€ã³ã¹ããŒã«æ¹æ³ãããããŸããCPANãCPANMãªã©ã®ã³ãã³ãã䜿çšããŠäŸåããã¢ãžã¥ãŒã«ãã€ã³ã¹ããŒã«ããå¿ èŠããããŸãããããã®ããŒã«ã«äžæ £ããªå Žåã¯ãå ¬åŒããã¥ã¡ã³ããåç §ããããã³ãã¥ããã£ãªã©ã®ãªãœãŒã¹ã掻çšããããšã解決ã®äžå©ãšãªããŸãã
Perlã¹ã¯ãªããã®å®è¡ãããŸããããªããšãã¯ããshebangè¡ãã®ç¢ºèªãå¿ããã«ãshebangè¡ã¯ã¹ã¯ãªããã®å®è¡ã«äœ¿çšããã€ã³ã¿ãŒããªã¿ã®ãã¹ãæå®ãããã®ã§ãæ£ãããªããã¹ã«ãªã£ãŠãããšã¹ã¯ãªãããå®è¡ãããŸããã
6.2 ChatGPTãšé£æºããéã®ãããããã©ãã«ãšãã®å¯ŸåŠæ³
ChatGPTãPerlã¹ã¯ãªãããšé£æºãããéãAPIæ¥ç¶ã®èšå®ãã¹ããã©ãã«ã®äžå ãšããŠæããããŸããAPIããŒãæ£ããèšçœ®ãããŠãããããšã³ããã€ã³ãã®URLãæ£ç¢ºããªã©ãåºæ¬çãªèšå®ãå確èªããããšãéèŠã§ãã
ãŸããChatGPTãæ³å®ããã¬ã¹ãã³ã¹ãè¿ããªãå ŽåãJSONãã©ãŒãããã®åãæ±ãã«åé¡ãããå¯èœæ§ããããŸããPerlã§ã¯ã`JSON`ã¢ãžã¥ãŒã«ã䜿çšããŠAPIããã®ã¬ã¹ãã³ã¹ãåŠçããããšãäžè¬çã§ããã¬ã¹ãã³ã¹ãé©åã«ããŒã¹ãããŠãããããã§ãã¯ããŸãããã
éä¿¡ãšã©ãŒãçºçããããšãå€ã ãããŸãããã®å ŽåãPerlã®`LWP::UserAgent`ã¢ãžã¥ãŒã«ãªã©ã䜿çšããŠããå Žåã¯ãã¿ã€ã ã¢ãŠãã®èšå®ããªãã©ã€ããžãã¯ã®å®è£ ãªã©ãæ€èšããã®ãè¯ãã§ãããããããã¯ãŒã¯ã®ç¶æ ããµãŒããŒã®è² è·ã«ãã£ãŠã¯ãããããã®è©Šè¡ãå¿ èŠã«ãªããããããŸããã
6.3 ã¹ã¯ãªããã®æé©åãšããã©ãŒãã³ã¹åäž
Perlã¹ã¯ãªããã®å¹çãåäžãããã«ã¯ããèšç®ã³ã¹ãã®é«ãæäœã®åæžããã«ã®ã§ããããšãã°ãæ£èŠè¡šçŸã®äœ¿çšã¯éåžžã«äŸ¿å©ã§ãããè€éãªãã¿ãŒã³ã倧èŠæš¡ãªããã¹ãåŠçã«ãããŠã¯ããã©ãŒãã³ã¹ã«åœ±é¿ãäžããŸããããã·ã³ãã«ãªåŠçã«æžãæããããéšåã¯ãªããèŠçŽããŸãããã
ããããã¡ã€ãªã³ã°ããŒã«ãã䜿çšããããšãå¹æçã§ããDevel::NYTProfãªã©ã®ãããã¡ã€ãªã³ã°ããŒã«ã¯ãã¹ã¯ãªããã®ã©ã®éšåãå®è¡æéãå ããŠãããã詳现ã«åæããŠãããŸããããã«ãããæé©åã®å¿ èŠãªã³ãŒãéšåãç¹å®ãããããªããŸãã
æç¶çãªæé©åã®ããã«ã¯ãããã³ãããŒã¯ãåããããšã倧åã§ããBenchmarkã¢ãžã¥ãŒã«ã䜿çšããŠãã³ãŒãã®æ¹åååŸã§å®è¡æéãæ¯èŒããããšã§ãå¹çåã®ææãå ·äœçã«æž¬å®ããããšãã§ããŸãã
6.4 ä»åŸã®Perlããã°ã©ãã³ã°ãšAIã®åå
Perlããã°ã©ãã³ã°çéã§ã¯ãAIã®å©çšãé²ãã§ããŸãããPerlãä»ã®èšèªã«æ¯ã¹ãŠç¹æ®µãAIåéã§åŸããåã£ãŠãããšããããã§ã¯ãããŸãããCPANã«ã¯AIãæ©æ¢°åŠç¿çšã®ã¢ãžã¥ãŒã«ãæã£ãŠããããããã䜿ã£ãŠååã«æéãªéçºãå¯èœã§ãã
ChatGPTã®ãããªå é²çãªæè¡ãPerlã§æŽ»çšå¯èœã§ãããã§ã«APIãéããé£æºäŸãå ±åãããŠãããPerlã®æè»æ§ãçããããããã¿ã€ãéçºã«ã¯é©ããŠããŸããã€ã³ã¿ãŒããªã¿èšèªãšããŠã®ãªã¢ã«ã¿ã€ã æ§ãPerlã®å€§ããªå©ç¹ã§ãã
å°æ¥çã«ã¯ãããçºå±ããAIæ©èœãPerlã¹ã¯ãªããã«çµ±åããåããäºæ³ãããŸããAPIã®é²åã«ãããããã°ã©ããŒã¯ããé«åºŠãªAIæ©èœãç°¡åã«åãå ¥ããããããã«ãªãã§ãããããPerlã®æè»æ§ãæ°ããªå¯èœæ§ãåºãããšèããããŸãã
ãŸãšã
ChatGPT Perlããã°ã©ãã³ã°ã¯ãããžãã¹ã®ããã¹ãåŠçãèªååã«æé©ãªæè¡ã§ããPerlã®æè»æ§ãšChatGPTã®AIæ©èœãçµã¿åãããããšã§ãå¹ççãªã³ãŒãäœæãå¯èœã«ãªããŸããããã¹ãåŠçã®è±å¯ãªã©ã€ãã©ãªãšç°¡æœãªææ³ã¯Perlã®åŒ·åãªç¹åŸŽã§ããããããã掻çšããã°ç°¡åãªChatbotããè€éãªããŒã¿è§£æãŸã§ãããŸããŸãªã¹ã¯ãªãããå®çŸå¯èœã§ããå®å šãªAPIæ¥ç¶ãåŠã³ãPerlã³ãã¥ããã£ã®ãµããŒããåããªããChatGPTã䜿ã£ãããã°ã©ãã³ã°ãå§ããŠã¿ãŸãããããŸãã¯åºæ¬çãªææ³ããã¹ã¿ãŒããå®è·µçãªã¹ã¯ãªããäŸãè©ŠããŠã¿ãã®ãããããã§ãã