FAQ - Perlã§ãããã質åã«çãã
Perl
›
FAQ
Perlã§ãã訪ãããã(ã§ããã)質åã«ã¤ãã¦æ¸ãã¦ã¿ããã¨ãããã¾ãã
å¼æ°ã®ãªãshifté¢æ°ã¯ã©ãããæå³ã§ãã
Perlã®ã½ã¼ã¹ã³ã¼ãã§ã¯ãå¼æ°ã®ãªãshifté¢æ°ãããè¦ãããã¨æãã¾ããå¼æ°ã®ãªãshifté¢æ°ã®æå³ã¯æ¬¡ã®ããã«ãªãã¾ãã
- ãµãã«ã¼ãã³ã®ä¸ã§ã¯ããµãã«ã¼ãã³ã®å¼æ°ã®ç¬¬ä¸å¼æ°ãåã£ã¦ãã
- ãã以å¤ã®å ´æã§ã¯ãã³ãã³ãã©ã¤ã³å¼æ°ã®ç¬¬ä¸å¼æ°ãåã£ã¦ãã
sub foo { # ãmy $x = shift @_;ã ã¨åãæå³ my $x = shift; } # ãmy $y = shift @ARGV;ãã¨åãæå³ my $y = shift;
Perlã§æ¥æ¬èªãæ±ããã¨ã¯å¯è½ã§ãã
ãPerlã¯ã»ã¼å®å ¨ã«Unicodeã«å¯¾å¿ãã¦ããè¨èªã§ããã¾ãããããã®ã¨ã³ã³ã¼ãã£ã³ã°ããµãã¼ããã¦ããã®ã§ããã¾ãã¾ãªç°å¢ã§æåãæ±ããã¨ãã§ãã¾ããPerlã§æ¥æ¬èªãæ±ãåèã¨ãã¦ä»¥ä¸ã®è¨äºãåèã«ãã¦ã¿ã¦ãã ããã
ãjcode.plãJCode.pmã¯ç¾å¨ã§ã¯æ¨å¥¨ãããææ³ã§ã¯ãªããªã£ã¦ããã®ã§ãEncode.pmãå©ç¨ããç¾ä»£ã®æ¨æºçãªææ³ãå¦ãã§ã¿ã¦ãã ããã
Perlã«ä¾å¤å¦çã¯ããã¾ãã
ãã¯ããããã¾ããPerlã§ã¯evalãããã¯ã¨ããæ§æã使ãã¾ããä¾å¤ãçºçããå ´åã¯$@ã¨ããå¤æ°ã«ä¾å¤ã®å 容ãä»£å ¥ãããã®ã§ãã§ãã¯ãã¾ãã
# ä¾å¤å¦ç eval { ... } # ä¾å¤ãçºçããå ´åã®å¦ç if ($@) { ... }
ãç¹å¥ãªã¢ã¸ã¥ã¼ã«ãå©ç¨ããå¿ è¦ã¯ãªããããã©ã«ãã®æ©è½ã¨ãã¦ä¾å¤å¦çã¯ç¨æããã¦ãã¾ãã
æååãé¢æ°ã使ã£ã¦æä½ãããã§ã
ãPerlã«ã¯ãããããªæååé¢æ°ãç¨æããã¦ãã¾ããよく使用する関数・モジュール一覧ã®ãæååæä½ãã¨ããé ç®ãèªãã§ã¿ã¦ãã ããã
Perlã§ã¯å¤æ°ã®ã¹ã³ã¼ãã¯ã©ã®ããã«ãªã£ã¦ãã¾ãã
Perlのスコープを理解するã¨ããè¨äºã§Perlã®ã¹ã³ã¼ãã«ã¤ãã¦è§£èª¬ãã¦ãã¾ãã
æ¥ä»ãæ±ãæ¨æºçãªæ¹æ³ã¯ããã¾ãã
ãPerl5.10以éã§ããã°ãTime::Pieceã¨ããã¢ã¸ã¥ã¼ã«ãæ¨æºã§æ·»ä»ããã¦ãã¾ããTime::Pieceモジュールの解説ãèªãã§ã¿ã¦ãã ããã
Perlã§èªå試é¨ãè¡ããã¨ã¯ã§ãã¾ãã
ãã¯ããèªå試é¨ãè¡ããã¨ãã§ãã¾ããèªå試é¨ã«ã¤ãã¦ã¯自動試験(Perl逆引き事典)ãåèã«ãã¦ã¿ã¦ãã ããã
Perlã§Webã¢ããªã±ã¼ã·ã§ã³ãä½æããã«ã¯CGIãå©ç¨ããããæ¹æ³ã¯ããã¾ããã
ãç¾å¨ã§ã¯ãã¾ãã¾ãªæ¹æ³ãå¯è½ã§ããCGIã使ãã»ãã«ãApacheä¸ã®mod_perlã§å®è¡ããæ¹æ³ãFastCGIãããã³ã«ã使ã£ã¦å®è¡ããæ¹æ³ãPSGIã¨å¼ã°ãããããã³ã«ãå©ç¨ãã¦å®è¡ããæ¹æ³ãªã©ã§ãã
ãç°¡åã«Webã¢ããªã±ã¼ã·ã§ã³ãè¨è¿°ãããã®ã§ããã°ãCGIã¢ã¸ã¥ã¼ã«ã使ãããããMojoliciousã¨ãããã¬ã¼ã ã¯ã¼ã¯ã®ä¸ã®Mojolicious::Liteã¨ããã¢ã¸ã¥ã¼ã«ãå©ç¨ããã®ãããã§ãããã
Perlã¯CGIãå®ç¾ããããã®ããã°ã©ãã³ã°è¨èªã§ãã
ãããããPerlã¯æ±ç¨çãªããã°ã©ãã³ã°è¨èªã§ããã¨ã¦ãå¤ãã®ãã¨ãPerlã§è¡ããã¨ãã§ãã¾ããCGIã¨ããã®ã¯ããã°ã©ã ãWebãµã¼ãã¼ä¸ã§å®è¡ããããã®ãããã³ã«ã®ãã¨ã§ãPerlã¨ã¯ç´æ¥çã«ã¯é¢ä¿ã¯ããã¾ããã
Webã¢ããªã±ã¼ã·ã§ã³ã®éçºã¯PHPã®ã»ããPerlãããç°¡åã§ãã
ãPerlã®CGI.pmã使ã£ãéçºã«æ¯ã¹ãã¨PHPã«ããWebã¢ããªã±ã¼ã·ã§ã³ã®éçºã¯æç¶ç°¡åã§ãããããã®ããå¤ãã®äººã¯PHPã®ã»ããç°¡åã«Webã¢ããªã±ã¼ã·ã§ã³ãéçºã§ããã¨æãã¦ããããã§ãã
ãã§ããMojoliciousãªã©ã®Webãã¬ã¼ã ã¯ã¼ã¯ãå©ç¨ããå ´åã¯ç´ ã®PHPã«ããWebã¢ããªã±ã¼ã·ã§ã³éçºãããããã«é«ãéçºå¹çãå¾ããã¨ãã§ãã¾ããããã«ãè¨è¿°ããããã¦ç°¡æ½ã«ãªãã試é¨ç°å¢ã®æ§ç¯ããããªããèªå試é¨ã«ããä¿¡é ¼æ§ã®é«ãã¢ããªã±ã¼ã·ã§ã³éçºãã¤ã³ã¹ãã¼ã«ã®å®¹æãããã¾ãã¾ãªç°å¢ã§å®è¡ã§ããæ±ç¨çãªã¢ããªã±ã¼ã·ã§ã³éçºãªã©ãã¾ãã¾ãªå©ç¹ãå¾ããã¨ãã§ãã¾ãã
ãæ¯ã¹ãã¨ãã®æ£ãã観ç¹ã¯ãPHP vs Perl+CGI.pmãã§ã¯ãªãããPHP vs Perl+Webãã¬ã¼ã ã¯ã¼ã¯ãã§ããã¨ãããã¨ãèªèãã¦ãããã¨ã¯å¤§åã§ãã
PHPã¯Perlãããé«éã§ãã
ããããããæ¸ç±ãªã©ã§æ¸ããã¦ãããã¨ãå¤ãã§ãããå®å ¨ãªèª¤è§£ã§ããPHPã¨ããè¨èªã¨Perlã¨ããè¨èªãæ¯ã¹ãå ´åãå¦çé度ã¯ããã»ã©å¤ããã¾ããã
ãããPHPã¯CGIããéãã¨æ¸ããã¦ãã¾ãããCGIã«ã¤ãã¦èª¤è§£ããä¸ã§ã®è¨è¿°ã§ããCGIã¨ã¯ãããã³ã«ã®ãã¨ã§Perlã¨ã¯ä½ã®é¢ä¿ãããã¾ãããã¤ã¾ãCGIãå©ç¨ããPHPãCGIãå©ç¨ããCè¨èªãCGIãå©ç¨ããPerlãããã¾ãã
ãCGIã§æ¸ãããPHPã¯ãCGIã§æ¸ãããPerlã¨åããããä½éãªé度ã§ããApacheä¸ã®mod_phpã§åãPHPã¯ãApacheä¸ã®mod_perlã§åãPerlã¨åããããé«éã§ããã¾ãPSGIã¨ãããããã³ã«ä¸ã§åãPerlã¯ãApacheä¸ã®mod_phpã§åãPHPã¨åããããé«éã§ãã
ãã¤ã¾ãé度æ¯è¼ã¨ããã®ã¯ãPHPã¨Perlã®ã©ã¡ããé¸ã¶ãã¨ããè¨èªé¸æã«ããã¦ã¯ã»ã¨ãã©æå³ãæã£ã¦ãã¾ããã
Perl6ã¨Perl5ã®é¢ä¿ã«ã¤ãã¦æãã¦ãã ããã
Perl6ã¯éå»ã«Perl5ã®å¾ç¶ã¨ãã¦éçºããã¦ãã¾ããããç¾å¨ã¯ãPerl6ã¯Perl5ã¨ã¯å¥ã®ããã°ã©ãã³ã°è¨èªã§ããPerl6ã¯ã2016å¹´12æã«æ£å¼ã«ãªãªã¼ã¹ããã¾ãããç¾è¡ã®Perlã§ããPerl5ã¯ãå°æ¥ã«ããã£ã¦éçºãç¶ãããµãã¼ãããããã¨ãç´æããã¦ãã¾ãã
詳ããã¯ä»¥ä¸ã®èª¬æãã覧ãã ããã
ããããè¦ã¦ããã¨Perlãå¦å®çã«è©ä¾¡ãããã¡ãªã®ã¯ãªãã§ããã
ãããããªåå ãèãããã¾ãããã»ã¨ãã©ã®äººãè¨èªã®æç¨æ§ã§ã¯ãªããè¨èªã®ã¤ã¡ã¼ã¸ã§èªã£ã¦ããããã§ãããã¨ãã°ãæ°ããããå¤ããã¨ãã£ãæ¼ ç¶ã¨ããã¤ã¡ã¼ã¸ã§ããæ°ããè¨èªã好ããªäººã¯Perlã«å¯¾ãã¦å¤ãã¨ããã¤ã¡ã¼ã¸ãæã¡ãã¡ã«ãªãã®ã ã¨æãã¾ããã¾ãPerl4ã®æ代ã«ä¿å®æ§ã®æªãPerlã¹ã¯ãªãããä¿å®ãããããã¨ããè¦ãçµé¨ãæªãã¤ã¡ã¼ã¸ã«ã¤ãªãã£ã¦ããã®ããããã¾ããã
ã¾ãPerl6ã®èªçããããã¦ãã10å¹´ããã£ã¦ããã®ã§ãPerl5ã«å¯¾ãã¦å»ããã¤ã¡ã¼ã¸ãæã£ã¦ãã人ãå¤ãã§ããããä¸ã®ä¸ã®æµãã¯Perlã«å¯¾ãã¦å¤å ¸çãªã¤ã¡ã¼ã¸ãæ±ãããã¡ãªé°å²æ°ã«ãªã£ã¦ãã¾ãããPerlã®ã³ãã¥ããã£ã«ãåå ãããã¾ãããPerlã§ã¯ãªãè¨èªã®ã³ãã¥ããã£ã«ãåå ãããã®ã§ãããã
ä»ã®ã¹ã¯ãªããè¨èªã¨æ¯è¼ããPerlã®è¯ãç¹å¾´ã¯ãªãã§ãã
ãã²ã¨ã¤ã¯ããããã®ãã©ãããã©ã¼ã ã§å©ç¨ãããã¨ãã§ããããã©ã«ãã§ã¤ã³ã¹ãã¼ã«ããã¦ãããã¨ãå¤ãã¨ãããã¨ã§ãããã¨ãã°ããã°ã©ãã³ã°è¨èªãã¤ã³ã¹ãã¼ã«ãã権éããããªãã£ãã¨ãã¦ããPerlãå©ç¨ãããã¨ãã§ããå¯è½æ§ãé«ãã¨ãããã¨ã§ãã
ãã¾ãå¾æ¹äºææ§ãé常ã«é«ãã¬ãã«ã§ç¶æãããã®ã§ãä½æããã¹ã¯ãªããã¯ãä½ã®å¤æ´ããªãã«ãä»ã®ç°å¢ã§å®è¡ãããã¨ãã§ãã¾ããã©ã®ãã¼ã¸ã§ã³ãæèãã¦æ¸ããªããã°ãªããªãã¨ããæ©ã¿ã¯Perlã«ã¯ãã¾ãããã¾ãããPerlã®ãã¼ã¸ã§ã³ã®5.8ãæèãã¦è¨è¿°ããã°ãã»ã¨ãã©ã®ç°å¢ã§å®è¡ãããã¨ãã§ããã§ãããããã®ç¹ã«ã¤ãã¯Perlã¯ä»ã®ã¹ã¯ãªããè¨èªã¨æ¯ã¹ã¦ããªãã®é æ ®ãæããã¦ããã¦ã¼ã¶ã¼ã«åªããã§ãã
ãããããªããã¤ã³ãã©ã¨ã³ã¸ãã¢ã§ããã°ãPerlã¯ç¥ã£ã¦ããã¹ãè¨èªã®ä¸çªç®ã«å ¥ãã¨ãã£ã¦ãéè¨ã§ã¯ãªãã¨æãã¾ããå°æ¥ã«ããã£ã¦ã¹ã¯ãªãããå®å¿ãã¦åããç¶ãããã¨ãã§ãã¾ããã¾ãWebã¨ã³ã¸ãã¢ã§ããã°ãPHP,Ruby,Perlã®ãã¡ã®ã©ããä¸ã¤ãåå¼·ãããã¨ã«ãªãã¨æãã¾ãã
ãã¾ãããã¹ãå¦çã®å¦çé度ã¯éãã§ããããã¹ãå¦çãä¸è¬çã«è¡ãç°å¢ã§ããã°ãããããRubyã®2å以ä¸ã®é度ã§ããã¹ãå¦çãè¡ããã§ããããããã¯1æéãããå¦çã30åã§çµãããã¨ãã§ããã¨ãããã¨ã§ããããã¹ãå¦çã«ãããããã°ã©ãã³ã°ã®è¨è¿°æ§ã¨ããã©ã¼ãã³ã¹ãèããã¨Perlã¯æåã®è¨èªã§ããã¨ãããã§ãããã
ãã¾ãä»ã®ã¹ã¯ãªããè¨èªã¨æ¯è¼ããã°çã¡ã¢ãªã§ãããã³ã³ãã¤ã«é度ãé«éã§ããã¾ãPerlã¯ä»ã®äººãã¤ã¡ã¼ã¸ãã¦ããã®ã¨ã¯ç°ãªããã¹ã¯ãªããããããã«æ¸ããã¨ãã§ããè¨èªã®ã²ã¨ã¤ã ã¨ãããã¨ãæ¼ããã¦ããã¹ããã¤ã³ãã§ããè¨è¿°æ§ã«ããã¦RubyãPythonããã¹ãã¨å¼ã°ãããªãã°ãPerlã¯å°ãã ãåã°ãªãã§ãããããªããã¿ã¼ã¨å¼ã¹ãããããããã«ããã¾ãã
ãCPANã¨å¼ã°ããç¡æã§å©ç¨ã§ããã¢ã¸ã¥ã¼ã«ãè±å¯ã«ããã¨ããã®ã大ããªé åã®ä¸ã¤ã§ããPerlæ¬ä½ã§ã§ããªããã¨ããã£ãå ´åã«ã¯ãCPANã«ããã¢ã¸ã¥ã¼ã«ã調ã¹ãã¨ã»ã¨ãã©ã®å ´åã«è§£æ±ºãããã¨ãã§ããã§ãããã
ãã¾ãWebã¢ããªã±ã¼ã·ã§ã³ãã¨ã¦ãä½æããããç°å¢ãããã¨ããã®ããå©ç¨ãããã¤ã³ãã«ãªãã§ããããMojoliciousã¨ããã¨ã¦ã使ããããWebãã¬ã¼ã ã¯ã¼ã¯ãããã¾ãã
ãã¨ããããã§ãPerlã¯ãã¸ãã¹ç¨éã«ãé©ããè¨èªã§ããã¨ãããã¨ããããã¨æãã¾ãã
Perl4(Perlã®ãã¼ã¸ã§ã³4)ãå¦ã¶å¿ è¦æ§ã¯ããã¾ããã
ãã¤ã³ã¿ã¼ãããã«ã¯Perl4ã§ãåãããã¹ã¯ãªããã¯å¤ãã§ãããç¾å¨ã§ã¯Perl4ãæèãã¦Perlãæ¸ãå¿ è¦ã¯ãªãã¨ãã£ã¦ãããã§ããããPerl5ã®æ®åçã¯ã»ã¼100%ã§ãã®ã§ãä¿å®æ§ãå¯èªæ§ãæè»æ§ã«åªããPerl5ã®è¨æ³ã§æ¸ãã®ãè¯ãæ¹æ³ã§ããPerl5ã¯ãå¯èªæ§ãä¿å®æ§ã«ããã¦ãæ¹åããã¦æ°ãããªã£ã¦ãã¾ãã
ã·ã¸ã«ã$@%ãããªãããªãã®ã§ããã
ããã°ããPerlãå©ç¨ãã¦ããã¨æ £ãã¦ããã¨æããã¾ããã·ã¸ã«ã®å©ç¹ãæ¸ãã¦ããã¨ããããå¤æ°ã ã¨ãããã¨ãè¦è¦çã«ãããã¨ãããã¨ã§ããä»ã®è¨èªã¨æ¯è¼ããã¨Perlã«æ £ãã¦ããªãã®ã§èªã¿ã«ããæããã¨æãã¾ãããæ £ãã¦ããã¨ãããå¤æ°ã ã¨ãããã¨ãè¦è¦çã«ãããã®ã§ããã£ã¦èªã¿ããããªãã¾ããã¾ãé¢æ°åã¨å¤æ°åãè¡çªããã¨ãããã¨ã¯çµ¶å¯¾ã«èµ·ãããªãã®ã§ãããã°ã©ãã³ã°ãããã¨ãã«ãäºç´èªã¯ãªãã ã£ãããªãã¨ãããã¨ãèãã¦ããã°ã©ã ããå¿ è¦ããªãã®ã§ãã¹ãã¬ã¹ãªãããã°ã©ãã³ã°ãã§ãã¾ãã
Perlã®ã½ã¼ã¹ã³ã¼ãã¯1é±éãã¤ã¨èªåã§ãèªããªããªãã¨ãããããã¯æ¬å½ã§ãã
ãããããä»ã®è¨èªã¨åãããã«ãããããããè¨è¿°ããã°èªãã¾ããããããã«ããè¨è¿°ããã°èªã¿ã«ãããªãã¾ããç¾ä»£ã®Perlã¯Perl5ã¨å¼ã°ããä¸æåã®Perlã§ã¯ãªããèªã¿ããããä¿å®æ§ãå¤§å¹ ã«æ¹åããã¦ãã¾ããä»ã®ã¹ã¯ãªããè¨èªã«å£ããããããããå¦çãè¨è¿°ãããã¨ãã§ãã¾ããä¸æåã«æ¸ãããã½ã¼ã¹ã³ã¼ããèªããã¨ããã¨ãèªãã®ãé£ããã¨ããã®ã¯äºå®ã ã¨æãã¾ãããPerlè¨èªãã®ãã®ãåå ã§ã¯ããã¾ãããåã«è¯ãã½ã¼ã¹ã³ã¼ããè¨è¿°ããããã®ç¥èãèããããåã«ããããã®ã³ã¼ããæ¸ãããã¨ãããã¨ã§ãã
ããã¨ãã°ã²ã¨ã¤ã®ä¾ã¨ãã¦ä»£è¡¨çãªWebãã¬ã¼ã ã¯ã¼ã¯ã§ããPerlã®Mojoliciousã¨Rubyã®Ruby on Railsã®ã½ã¼ã¹ã³ã¼ããæ¯è¼ãã¦ã¿ã¾ããããã©ã¡ããèªã¿ãããã¨æãã¾ãã?
Perlã¯å¤ãã¨ããã®ã¯æ¬å½ã§ãã
ãèµ·æºãå¤ãã¨ããæå³ã§ããã°æ¬å½ã§ããPerlã¯1987å¹´çã¾ãã®è¨èªã§ããããã©ãå¤ãã¨ããã®ã¯ä½¿ããªãã¨ãä¸ä¾¿ã ã¨ããæå³ã§ã¯ããã¾ãããPerlã¯ç¾ä»£çãªããã°ã©ãã³ã°è¨èªã¨ãã¦å¤ãã®åéã§å©ç¨ããã¦ãã¾ãããã³ãã¥ããã£ã¯æ´»çºã§ãå®æçã«è¨èªã®ãã¼ã¸ã§ã³ã¢ããããªããã¦ãã¾ããææ°ã®æè¡ã«å¯¾å¿ããã¢ã¸ã¥ã¼ã«ã¯ã³ãã¥ããã£ã«ãã£ã¦æ´»çºã«CPANã«ãªãªã¼ã¹ããã¦ãã¾ããã¾ã大éã®ã¢ã¯ã»ã¹ãå¦çããå¿ è¦ã®ããWebã®åéã§Perlãå©ç¨ãã¦ããä¼æ¥ã¯å¤ãããã¾ãã
PythonãRubyã¯Perlãé²åãããè¨èªã§ãã
ãé²åãããã¨ããããã¯åèã«ããã¨ããã»ããæ£ç¢ºã§ãããã3ã¤ã®è¨èªã¯ããã«ã¦ãã¦ãã¿ã£ã¤ã®è¨èªãè¡ããã¨ãã§ããããã°ã©ãã³ã°ã®åéã¯ããä¼¼ã¦ãã¾ããããããã«ããã°ã©ãã³ã°è¨èªã¨ãã¦åæ§çãªä¸é¢ãããã¨ãã£ãã»ããããã§ãããããã æ å ±ãéµåã¿ã«ããã®ã§ã¯ãªãã¦ãå®éã«ç¢ºããã¦ã¿ãã¨ããã®ã¯å¤§åãªãã¨ã§ãã
ãPerlã«å¯¾ãã¦å¦å®çã§PythonãRubyãè¦ããããã¨ãã¯ãã®çç±ãèãã¦ã¿ã¾ãããããæ°ããã¦ãããã«ããããã¨ã¦ããã°ãããããã¨ãããã¨ããæãã¦ãããªãããã°ããã®äººã¯è¨èªã«ã¤ãã¦ãã¾ãç¥ããªãå¯è½æ§ãé«ãã§ãã
CãJavaã®ããã«åããªãã®ã§èªç±ããã¦é¦´æãã¾ãã
ãPerlãRubyãPythonãªã©ã®ã¹ã¯ãªããè¨èªã§ã¯ãå¤æ°(Perlã§ã¯ã¹ã«ã©å¤æ°)ã«ã©ã®ãããªåã®ãªãã¸ã§ã¯ãã§ãä»£å ¥ãããã¨ãã§ãã¾ãã
# Perl my $url = URL->new; # Java URL url = new URL();
ãéçãªè¨èªãå¦ãã§ãã人ã«ã¨ã£ã¦ã¿ãã°ããã®é¨åã ããè¦ãã¨æ±ãã«ããè¨èªã¨è¦ããããããã¾ããã
ãã§ãããåããªãã¨ãããã¨ã¯ãéçè¨èªã«æ¯ã¹ã¦æããã«å¤§ããããå©ç¹ãããã¾ããã²ã¨ã¤ãã¯ã¡ã½ããã®ãªã¼ãã¼ãã¼ãã«ã¤ãã¦ä½ãèããå¿ è¦ããªãã¨ãããã¨ã§ããC++ãJavaã«ã¯ã¡ã½ããã®ãªã¼ãã¼ãã¼ãã¨ããæ©è½ãããã¾ããããã¯ã¡ã½ããã®å¼æ°ã®åãç°ãªã£ãå ´åã«ãåãååã®ã¡ã½ãããå®ç¾©ã§ããæ©è½ã§ãããã¨ãã°æµ®åå°æ°ç¹åãå¼æ°ã«ã¨ãã¡ã½ããã¨æ´æ°ãå¼æ°ã«ã¨ãã¡ã½ããã¯å¥ã«è¨è¿°ããªããã°ãªãã¾ããã
# Java int sum(double num1, double num2) { ... } double sum(double num, double num2) { ... }
ãä¸æ¹åçã«åãæã¤è¨èªã§ã¯ã²ã¨ã¤ã ãã§ãã¿ã¾ããããã¯éè¤ããªããã¨ããæå³ã§ä¿å®æ§ã¯å¤§å¹ ã«é«ã¾ãã¾ãã
sub sum { }
ã第äºã«C++ã®ãããªãã³ãã¬ã¼ãã¯ã©ã¹ãèããå¿ è¦ã¯ãªãã¨ãããã¨ã§ããã©ã®ãããªåã§ãåãåããã¨ãã§ããã®ã§ãã¡ã½ãããã¯ã©ã¹å®ç¾©ã«ããã¦åã«å¿ãã¦ä½ããããã¨ããè¨è¿°ãè¡ãå¿ è¦ãããã¾ããã
ã第ä¸ã«(Javaã«ããã)ã¤ã³ã¿ã¼ãã§ã¼ã¹ãèããå¿ è¦ããªãã¨ãããã¨ã§ããJavaã®ã¯ã©ã¹ã®è¨è¨ã¯å ±éã®ã¤ã³ã¿ã¼ãã§ã¼ã¹ãèããã¨ããã¨ã¦ãé£ããä½æ¥ãä¼´ãã¾ããæ±ç¨æ§ãé«ãããã¨ããã¨ã¤ã³ã¿ã¼ãã§ã¼ã¹ã®è¨è¨ã¯ããããªããã®ã«ãªãã§ããããåçè¨èªã®å ´åã¯ã©ã®ãããªåããã¤ãªãã¸ã§ã¯ãã§ãã£ã¦ããå¤æ°ã«ä»£å ¥ãããã¨ãã§ããã¡ã½ãããå®è¡æã«å¼ã³åºãã®ã§ãã®ãããªå¿é ããããã¨ãããã¾ããã
ãã§ããããåããªãã¨ãããã¨ããã¤ãã¹ã«è¦ãã®ã§ã¯ãªãã¦ãä¿å®æ§ã®é«ãéè¤ã®ãªãç°¡æ½ãªããã°ã©ãã³ã°ãè¨è¿°ãããã¨ãã§ããã¨ããåçè¨èªã®ãã©ã¹ã®é¢ã«ç®ãåãã¦ã¿ãã®ã¯ã©ãã§ããããå®éã«ããã°ã©ãã³ã°ãç°¡åã«è¨è¿°ã§ããã¨ãããã¨ãããã£ã¦ãããã¨æãã¾ãã
大è¦æ¨¡ãªããã°ã©ã ãPerlã§ä½æãããã¨ãã§ãã¾ãã
ãã¯ããPerlã¯å°ããªããã°ã©ã ãä½æããã®ã«åãã¦ããã¨èãããããã¨ãããã¾ãããããªãã¨ã¯ããã¾ããããã¨ãã°å¤§ããªããã°ã©ã ã¯Javaã§ãå°ããªããã°ã©ã ã¯Perlã§ä½ããã¨ãããã£ããããªã¤ã¡ã¼ã¸ãæã£ã¦ããã¨ãã¦ããPerlã¨ããè¨èªã誤解ãã¦ãããã¨ã«ãªãã¾ãã
ãPerlã§æ¸ãã°éçãªè¨èªã§è¨è¿°ãããããããªãå°ãªãã³ã¼ãéã§å¤§è¦æ¨¡ãªã¢ããªã±ã¼ã·ã§ã³ãä½æã§ãããã¨ã«æ°ã¥ãã¨æãã¾ããã¾ã大è¦æ¨¡ãªã¢ããªã±ã¼ã·ã§ã³ãä½æããã®ã«å°é£ã¨æããé¨åã¯ãªãã¨ãããã¨ã«ãæ°ã¥ãã¨æãã¾ãã
ããã¨ãã°ã²ã¨ã¤ã®ä¾ã¨ãã¦Amazonã¨ãããµã¤ãã¯Perlã§è¨è¿°ããã¦ããã¨ãããã¨ãèããã°ãPerlã¯å¤§è¦æ¨¡ãªããã°ã©ãã³ã°ã«åãã¦ã¯ããªãã®ã§ã¯ãªããã¨ãã誤解ã¯è§£ããã®ã§ã¯ãªããã¨æãã¾ãã
Perlã§ãªãã¸ã§ã¯ãæåããã°ã©ãã³ã°ãè¡ããã¨ãã§ãã¾ãã
ãPerlã§ãªãã¸ã§ã¯ãæåããã°ã©ãã³ã°ãè¡ããã¨ã¯å¯è½ã§ããããªãã¸ã§ã¯ãæåããã°ã©ãã³ã°ãè¡ãããã®ååãªæ©è½ãåãã¦ãã¾ãããã ãä»ã®ãªãã¸ã§ã¯ãæåè¨èªã¨ã¯ãã¯ã©ã¹ã®ä½æãè¡ãæé ãå°ãç°ãªãã¾ãããã®ããã«ãåãã¦ãªãã¸ã§ã¯ãæåããã°ã©ãã³ã°ãããå ´åã¯ãããããå¦ç¿ã³ã¹ããä»ã®è¨èªããé«ãæãã¦ãã¾ãã§ããããã¾ãPerlã®ãªãã¸ã§ã¯ãæåã®è¨è¿°ã¯ãä»ã®ã¹ã¯ãªããè¨èªãããæéããããã¨ããã®ã¯æ¬å½ã§ããã¢ã¸ã¥ã¼ã«ã使ãã°ä»è¨èªã¨åãç¨åº¦ã«è¨è¿°ã軽æ¸ã§ãã¾ãããPerlã®ã³ã¢ã«ã¯æ¨æºçãªãªãã¸ã§ã¯ãæåã¢ã¸ã¥ã¼ã«ãå«ã¾ãã¦ããªãã®ã§ãCPANãããªãããã®ã¢ã¸ã¥ã¼ã«ãå©ç¨ãããã¨ã«ãªãã§ãããã
ããã¨ãã°Object::Simpleã使ãã¨ä»¥ä¸ã®ããã«è¨è¿°ã§ãã¾ãã
package Point; use Object::Simple -base; has x => 0; has y => 0; 1;
ãåºåºã¯ã©ã¹ã®ç¶æ¿ã
package Point3D; use Object::Simple 'Point'; has z => 0; 1;
ãä»ã®è¨èªã«å£ããã·ã³ãã«ãªã¯ã©ã¹ã®è¨è¿°ãå¯è½ã§ãã
CentOSã§Perlã®æ¨æºã¢ã¸ã¥ã¼ã«(ã³ã¢ã¢ã¸ã¥ã¼ã«)ã使ãã¾ãã
ããããVPSã§Centos6ã試ãã¦ã¿ã¦æ°ã¥ãããã¨ãªã®ã§ãããããã©ã«ãã§ã¤ã³ã¹ãã¼ã«ããã¦ããPerl 5.10.1ã¯ãæ£è¦ã®Perlã§ã¯ãªãæãã§ããMojoliciousã¢ããªã±ã¼ã·ã§ã³ãåãããã¨ãã¦æ°ã¥ãããã¨ã§ãããæ¨æºã¢ã¸ã¥ã¼ã«ã®ä¸é¨ã足ãã¦ãã¾ããããªãã¦ãã£ããã
ã以ä¸ã®ããã±ã¼ã¸ãã¤ã³ã¹ãã¼ã«ãããã¨ã§ãã³ã¢ã¢ã¸ã¥ã¼ã«(æ¨æºã¢ã¸ã¥ã¼ã«)ãå©ç¨å¯è½ã«ãªãã¾ãã
yum -y install perl-core
CetnOS7以éãåãæ¹æ³ãã試ããã ããã