ããã¯ãUbuntu OnlineãFedora OnlineãWindows ãªã³ã©ã€ã³ ãšãã¥ã¬ãŒã¿ãŒããŸã㯠MAC OS ãªã³ã©ã€ã³ ãšãã¥ã¬ãŒã¿ãŒãªã©ã®è€æ°ã®ç¡æãªã³ã©ã€ã³ ã¯ãŒã¯ã¹ããŒã·ã§ã³ã® XNUMX ã€ã䜿çšããŠãOnWorks ç¡æãã¹ãã£ã³ã° ãããã€ããŒã§å®è¡ã§ããã³ãã³ã eperl ã§ãã
ããã°ã©ã ïŒ
NAME
ePerl - çµã¿èŸŒã¿ Perl 5 èšèª
VERSION
@V@
SYNOPSIS
ããŒã« [-d å=å€] [-D å=å€] [-B begin_delimiter] [-E çµäºåºåãæå] [-i] [-m
ã¢ãŒã] [-o åºåãã¡ã€ã«] [-k] [-I ãã£ã¬ã¯ããªã«ãžã§ããéå§ããŸãã] [-P] [-C] [-L] [-x] [-T] [-w] [-c] [å ¥åãã¡ã€ã«]
ããŒã« [-r] [-l] [-v] [-V]
DESCRIPTION
æœè±¡
ePerl ã¯ãPerl 5 ããã°ã©ã ã¹ããŒãã¡ã³ããå€æ°å«ãŸãã ASCII ãã¡ã€ã«ãã
Perl 5 ã³ãŒãã¯ãã¬ãŒã³ ASCII ããŒã¿ãééããŸãã ããŸããŸãªæ¹æ³ã§æäœã§ããŸãã
äžè¬çãªãã¡ã€ã«çæã¿ã¹ã¯çšã®ã¹ã¿ã³ãã¢ãã³ Unix ãã£ã«ã¿ãŸãã¯çµ±å Perl 5 ã¢ãžã¥ãŒã«
ãŸããåç㪠HTML ããŒãž ããã°ã©ãã³ã°ã®ããã®åŒ·å㪠Web ãµãŒã㌠ã¹ã¯ãªããèšèªãšããŠãæ©èœããŸãã
æŠèŠ
ãã® ããŒã« ããã°ã©ã 㯠çµã¿èŸŒã¿ ããŒã« 5 èšèª éèš³è ã ããã¯æ¬åœã«å®å šã§ã -
Perl 5 ã€ã³ã¿ããªã¿ãæèŒããŠããŸãããåŒã³åºãç°å¢ãšãœãŒã¹ ãã¡ã€ã«ãç°ãªããŸã
ããã©ã«ãã® Perl ã€ã³ã¿ããªã¿ (éåžžã¯å®è¡å¯èœãã¡ã€ã«) ãããã¬ã€ã¢ãŠããåªããŠããŸãã ããŒã« or ããŒã«5 ã»ãšãã©ã®
ã·ã¹ãã ïŒã ããã¯ã次ã®å²åŠãæã€äžè¬ç㪠ASCII ãã¡ã€ã«çæçšã«èšèšãããŠããŸãã
åã蟌㿠éåžžã®æ¹æ³ã§ã¯ãªããPerl 5 ããã°ã©ã ã³ãŒãã ASCII ããŒã¿ã«å€æããŸãã
ASCII ããŒã¿ã Perl 5 ããã°ã©ã ã«åã蟌ã¿ãŸã (éåžžã¯ãããŒã¿ãåŒçšããŠäœ¿çšããŸã)ã
ãprintãã¹ããŒãã¡ã³ã)ã ãããã£ãŠã次ã®ãããªãã¬ãŒã³ãª Perl ã¹ã¯ãªãããæžã代ããã«ã
#!/ãã¹/ãž/perl
"foo bar\n" ãå°å·ããŸãã
"baz quux\n" ãå°å·ããŸãã
for ($i = 0; $i < 10; $i++) { print "foo #${i}\n"; }
"foo bar\n" ãå°å·ããŸãã
"baz quux\n" ãå°å·ããŸãã
ããã ePerl ã¹ã¯ãªãããšããŠèšè¿°ã§ããŸãã
#!/ãã¹/to/eperl
fooããŒ
ããºã»ã¯ãã¯ã¹
<: for ($i = 0; $i < 10; $i++) { print "foo #${i}\n"; } :>
fooããŒ
ããºã»ã¯ãã¯ã¹
ePerl ããªã¢ã³ãã®ãœãŒã¹ ãã¡ã€ã« ã¬ã€ã¢ãŠãã¯ç°ãªããŸãããã»ãã³ãã£ã¯ã¹ã¯åãã§ãã
ã€ãŸããã©ã¡ãã®ã¹ã¯ãªããããŸã£ããåãçµæããŒã¿ããSTDOUTãã«äœæããŸãã
æå³
ePerl ã¯ãPerl 5 ã€ã³ã¿ããªã¿ã®ããã°ã©ãã³ã°èœåãçµã¿åãããåãªãæ¥çã³ãŒãã§ãã
ããªãããŒãªåã蟌ã¿æè¡ã䜿çšããã©ã€ãã©ãªã åã蟌ã¿ã®ããªãã¯ã¯æ¬¡ã®ãšããã§ãã
ãœãŒã¹ ãã¡ã€ã«ãæå¹ãª Perl ã¹ã¯ãªããã«å€æãããããååŸããŸãã å®å šã« ãã£ãäžäººã§è©äŸ¡ããã
Perl 5 ã€ã³ã¿ãŒããªã¿ã®å éšã€ã³ã¹ã¿ã³ã¹ã ãããéæããããã«ãePerl ã¯ãã¹ãŠã®ãã¬ãŒã³ã翻蚳ããŸãã
ã³ãŒãã (ãšã¹ã±ãŒãããã) Perl 5 æååã«é 眮ããŸã å°å· ãã¹ãŠãééããªããæ§ç¯ããŸã
åã蟌ãŸãããã€ãã£ã Perl 5 ã³ãŒãã ã芧ã®ãšãããePerl èªäœããŸã£ããåãããšãè¡ããŸãã
å éšçã«ã¯ãæããªããã°ã©ãããã¬ãŒã³ãª Perl çæã¹ã¯ãªãããäœæããå¿ èŠããããŸããã
ãã®ãããªåæ¯ãªã³ãŒãã®æ§è³ªã«ãããePerl ã¯å®éã«ã¯ããè¯ãè©Šã¿ã§ãã
çæããã ASCII ããŒã¿ã«ã¯ãå®éã«ã¯åçããŒã¿ãããéçãªããŒã¿ãå«ãŸããŠããŸãã èšãæããã°: ã
ePerl if ãã©ãŒã 欲ããã§ã ããž ç¶ãã ã æã of ã çæããã ASCII ããŒã¿ in å¹³é 圢åŒã§ã¢ãŒã«ã€ããããããžã§ã¯ããä¿åããŸãïŒ while ãã
ããã°ã©ãã³ã° äžéš åæ¯ ãã®ã çŽç²ãªåçããŒã¿ãçæããå Žåã«ã¯äœ¿çšããªãã§ãã ããã ããã«ãã
ãã¬ãŒã³ãª Perl ã¹ã¯ãªããã®éåžžã®ããã°ã©ã ã³ãŒãã«ã¯äœã®å©ç¹ããããŸããã ãããã£ãŠãéç
å²åãå°ãªããšã 60% ã§ãªââããã°ãå©ç¹ã¯æ¬ ç¹ã«ãªããŸãã
ePerl ã¯ããã®èµ·æºã«ãããŠãå®éã«ã¯æ¥µç«¯ãªç¶æ³ãã€ãŸã Web ãµãŒããŒãšããŠèšèšãããŸããã
ãªã³ã¶ãã©ã€ HTML ããŒãžçæçšã®ã¹ã¯ãªããèšèªã ããã«å žåçãªã±ãŒã¹ããããŸã
éåžžãããŒã¿ã® 90% ã¯çŽç²ãªéç HTML ã¿ã°ãšãã¬ãŒã³ ASCII ã§æ§æãããŸããã
æ®ãã® 10% ã¯ãããå€ãã®ããŒã¯ã¢ãã ã³ãŒããåçã«çæããããã°ã©ãã³ã°æ§é ã§ãã
ããããePerl ãæšæºã® Unix ãã£ã«ã¿ãªã³ã° ã©ã³ã¿ã€ã ã¢ãŒãã«å ããŠãµããŒãããçç±ã§ãã
CGI/1.1 ããã³ NPH-CGI/1.1 ã€ã³ã¿ãŒãã§ã€ã¹ã
çµã¿èŸŒã¿ ããŒã« æ§æ
å®éã«ã¯ã䜿çšããã Perl 5 ã® ePerl ãããââã¯å ã«æå¹ãª Perl ã³ã³ã¹ãã©ã¯ãã眮ãããšãã§ããŸãã
ã€ã³ã¿ããªã¿ã©ã€ãã©ãªãè©äŸ¡ã§ããŸãã ãã ããå¿ ãå®ã£ãŠããã ãããéèŠãªãã€ã³ããããã€ããããŸã
ePerl ã䜿çšãããšãã¯ãå¿ ãèŠããŠãããŠãã ããã
1. ããªãã¿ ã åžžã« ç Žæ£ãããŸããã
èšãã®ã¯äºçŽ°ãªããšã§ãããå°ãªããšãäžåºŠã¯èšåããå¿ èŠããããŸãã ePerl ãããââã¯åºåãæå
åžžã«ç Žæ£ãããePerl ãåã蟌㿠Perl ãèªèããããã«ã®ã¿å¿ èŠã§ã
æ§ç¯ããŸãã ãããã¯æçµåºåã«æž¡ãããããšã¯ãããŸããã
2. çæããã ã³ã³ãã³ã æã£ãŠããŸã ããž go ããž ãSTDOUTãã
ePerl ãããââã¯å ã§ãµãã«ãŒãã³ãå®çŸ©ããããããŒã¿ãèšç®ãããããããšãã§ããŸããã
ãSTDOUTããã¡ã€ã«ãã³ãã«ã«æ瀺çã«æžã蟌ãŸããããŒã¿ã®ã¿ãå±éãããŸãã ãã®ä»ã§ã¯
èšè: ePerl ãããââã¯ããSTDOUTãã«ã³ã³ãã³ããçæããªãå Žåãããã¯å®å šã«
æçµåºåã§ã¯ç©ºã®æååã«çœ®ãæããããŸãã ããããã³ã³ãã³ããçæããããšã
æçµåºåã® ePerl ãããââã¯ã®ãã€ã³ãã«é 眮ããŸãã éåžžãã³ã³ãã³ããçæãããŸã
ãã¡ã€ã«ãã³ãã«ãæå®ãããŠããªãå Žåã«æé»çã«ãSTDOUTãã䜿çšããçŽç²ãªãprintãæ§é ãä»ããŠã
3. çæããã ã³ã³ãã³ã on ãæšæºãšã©ãŒã åžžã« ãªãŒã ããž an ãšã©ãŒã
ãSTDERRããã¡ã€ã«ãã³ãã«ã§ã³ã³ãã³ããçæããããã³ã«ãePerl ã¯ãšã©ãŒã衚瀺ããŸãã
(STDERR ã³ã³ãã³ããå«ã)ã ããã䜿çšããŠããšã©ãŒãæž¡ããšãã«ãšã©ãŒã§çµäºããŸãã
ePerl ã¯åŒã³åºãç°å¢ããããã¯ããŸãã
4. å§ ã»ãã³ãã³ã
次ã®ãã€ã³ã 6 (äžèšãåç §) ãšãã»ãšãã©ã®ãŠãŒã¶ãŒãããã§ãªããšããäºå®ã®ããã
ePerl ã®å éšãããã¯å€æã念é ã«çœ®ããŠãããePerl ã¯æåŸã®éšåã«ã€ããŠè³¢æã§ãã
ã»ãã³ãã³ã éåžžããã¹ãŠã® ePerl ãããââã¯ã¯æåŸã®ã»ãã³ãã³ã§çµããå¿ èŠããããŸãã
<: cmd; ...; cmd; :>
ãã ããæåŸã®ã»ãã³ãã³ãæ¬ èœããŠããå Žåã¯ãePerl ã«ãã£ãŠèªåçã«è¿œå ãããŸãã
<: cmd; ...; cmd:>
ãæ£ããæ§æã§ãã ãã ããå Žåã«ãã£ãŠã¯ ePerl ã匷å¶ããå¿ èŠããããŸã ãè¿œå ãã
ã»ãã³ãã³ã 次ã«ã空çœä»¥å€ã®æåŸã®æåãšããŠã"_"ãïŒã¢ã³ããŒã¹ã³ã¢ïŒãè¿œå ã§ããŸãã
ãããã¯å ã®æåã䜿çšããŠãePerl ã«æåŸã®ã»ãã³ãã³ã匷å¶çã«æ®ãããšãã§ããŸãã ããã䜿çšããŠãã ãã
次ã®ãããªæ§é ã«ãªããŸã
<: if (...) { _:>
foo
<: } else { _:>
ããŒ
<: } :>
Perl ãã£ã¬ã¯ãã£ããããå€ãã® ePerl ãããââã¯ã«åæ£ãããå Žåã
5. éèš for ãå°å·ãã®ã¿ ãããã¯ã
ã»ãšãã©ã®å ŽåãePerl ã¯å€æ°ãè£éããããã ãã«äœ¿çšãããããã§ãã
<: $VARIABLE ãåºåããŸãã :>
ãã®çš®ã®æ§é ã®ã·ã§ãŒãã«ãããæäŸãããšäŸ¿å©ã§ãã ãããã£ãŠãePerl ã¯ã
æåã=ãã«ããã·ã§ãŒãã«ããã ããã«å®è¡ãããå Žå (ããã§ã¯ç©ºçœã¯äœ¿çšã§ããŸãã)
ePerl ãããââã¯ã®éå§ããªãã¿ã®åŸã«ãprintãã¹ããŒãã¡ã³ããæé»çã«ç¶ããŸãã
çæãããŸããã€ãŸããäžèšã®ãããã¯ã¯æ¬¡ãšåçã§ãã
<:=$VARIABLE:>
ã»ãã³ãã³ã¯èªåçã«è¿œå ããããããããã§ãåé€ãããŠããããšã«æ³šæããŠãã ããã
ïŒäžèšãåç §ïŒã
6. Special ã©ã€ã³çµäº æšãŠãŸã command for ePerl ãããã¯ã
ePerl ã¯ãã//ããšããååã®ç¹å¥ãªç Žæ£ã³ãã³ããæäŸããŸããããã¯ã次ã®æç¹ãŸã§ã®ãã¹ãŠã®ããŒã¿ãç Žæ£ããŸãã
çµäºãããã¯ã®çŽåŸã«æ¬¡ã®æ¹è¡æåãå«ãŸãã
ããªãã¿ã éåžžãæžããšãã¯
foo
<: $x = 1; :>
ã¯ãã¯ã¹
çµæã¯
foo
ã¯ãã¯ã¹
ePerl ã¯ãããšãæ¹è¡ã ãã§ãã£ãŠããePerl ãããââã¯ã®åšå²ã®ã³ãŒããåžžã«ä¿æããããã§ãã ã§ããã€
ããªããæžã
foo
<: $x = 1; :>//
ã¯ãã¯ã¹
çµæã¯
foo
ã¯ãã¯ã¹
ã"//"ãã«ããè¡æ«ãŸã§ã®å 容ããã¹ãŠåé€ãããããã é åå·¥æ¥çšååŠè£œåã® æ¹è¡ã
7. å¶é in 解æäžã
ã©ã®ããã°ã©ã ã«ãå¶éããããŸããePerl ãåæ§ã§ãã Perl ã®ãã³ãã£ãã£ããã¯ãPerl ãåã«æ©èœããã ãã§ã¯ãªãããšã§ãã
è±ããªèšèªã§ããããã®æ§æèŠçŽ ã解æãããšæãããèšèªã§ãã ããããããªãã¯
ãšãããã¬ãŒãºãç¥ã£ãŠããããã ã ããŒã« 解æã§ãã ããŒã«âã èããŠã¿ãŠãã ããã ãããæå³ããããšã¯
ããã¯ãePerl ã ePerl ãããââã¯èªäœã解æããããšããªãããšã§ãã ããã¯å®å šã«äŸåããŠããŸã
Perl ã€ã³ã¿ããªã¿ ã©ã€ãã©ãªãããã¯ããããå®è¡ã§ããå¯äžã®ã€ã³ã¹ã¿ã³ã¹ã§ããããã§ãã
ãšã©ãŒã ãããåé¡ã¯ãePerl ãå°ãªããšãéå§ãšçµäºãèªèããå¿ èŠãããããšã§ãã
ãããã® ePerl ãããââã¯ã®äœçœ®ã
æ¹æ³ã¯ XNUMX ã€ãããŸãã解æäžã«çµäºåºåãæåãæ¢ãããšãã§ããŸããã
åŒçšç¬Šã§å²ãŸããæååã¯æãèªèãããŸãã (çµäºåºåãæåã¯çŽç²ãªããŒã¿ãšããŠæ±ãããŸã)ã ãŸãã¯
次ã®çµäºåºåãæåãŸã§é²ãã§ããããçºçããŠããªããšèšãããšãã§ããŸãã
Perl ã³ã³ã¹ãã©ã¯ãå ã ePerl 2.0 ã§ã¯ 2.1 çªç®ã®ãã®ã䜿çšãããŸããããePerl XNUMX ã§ã¯
æåã®ãã®ã¯ãããããšã³ãã䜿çšããŠãããšãã«å€ãã®ãŠãŒã¶ãŒããã®æ¹æ³ãæãã ããæ¡çšãããŸãã
ã">ããªã©ã®åºåãæåã ãããå®éã«ã¯ãèè ã¯åã³ãã®æèŠãä¿®æ£ãã
æçµçã«ãePerl 2.2 以é䜿çšãããŠãã XNUMX çªç®ã®ã¢ãããŒãã䜿çšããããšã«ããŸããã ãªããªã
äžæ¹ãæåã®æ¹æ³ã§ã¯ãããç°¡åãªåºåãæåã䜿çšã§ããŸã (ããèªäœã¯ããŸãè¯ããã®ã§ã¯ãããŸãã)
ã¢ã€ãã¢)ãePerl å 㧠``"m|"[^"]+"|"'' ãªã©ã®æ§é ã䜿çšããããšå€±æããŸãã
ãããã¯ã ãããŠãPerl æ§é å ã®çµäºåºåãæåããšã¹ã±ãŒãããæ¹ãç°¡åã§ã (ããšãã°ã
åŒçšç¬Šã§å²ãŸããæååå ã®ããã¯ã¹ã©ãã·ã¥ãä»ããŠ)ãè€é㪠Perl æ§é ãæžãæããŠã
åŒçšç¬Šã®æ°ã
ãããã£ãŠãçµäºåºåãæåã Perl æ§é å ã§ãçºçããå Žåã¯åžžã«ãšã¹ã±ãŒãããå¿ èŠããããŸã
ã©ãã«ãããŠã
8. HTML ãšã³ãã£ã㣠å€æã
ePerl ã®äœ¿çšæ³ã® XNUMX ã€ã¯ãHTML ããŒãžã®ãµãŒããŒåŽã¹ã¯ãªããèšèªãšããŠäœ¿çšãããããã
HTML ãšãã£ã¿ãŒã«é¢é£ããŠããããåé¡ããããŸãã 圌ã㯠ePerl ãç¥ãããšãã§ããŸãã
ãããã¯ãªã®ã§ããšãã£ã¿ãŒå ã§ãããã®ãããã¯ãå ¥åãããšãéåžžãããã€ãã®ãããã¯ããšã³ã³ãŒããããŸãã
æåãšå¯Ÿå¿ãã HTML ãšã³ãã£ãã£ã åé¡ã¯ããã®ãšã³ã³ãŒãã£ã³ã°ã
ç¡å¹ãª Perl ã³ãŒãã«ã€ãªãããŸãã ePerl ã¯ãªãã·ã§ã³ãæäŸããŸã -C ãããã®ãšã³ãã£ãã£ããã³ãŒããããã
CGI ã¢ãŒãã§ã¯èªåçã«ãªã³ã«ãªããŸãã 以äžã®ãªãã·ã§ã³ã®èª¬æãåç §ããŠãã ãã -C
ã®ã¬ã€ãããåç §ãã ããã
ã©ã³ã¿ã€ã ã¢ãŒã
ePerl ã¯ã次㮠XNUMX ã€ã®ç°ãªãã©ã³ã¿ã€ã ã¢ãŒãã§åäœã§ããŸãã
ã¹ã¿ã³ãã¢ããŒã³ Unixã® filter ã¢ãŒã
ããã¯ãUnix ã·ã§ã«ããã®çæããŒã«ãšããŠäœ¿çšãããå Žåã®ããã©ã«ãã®æäœã¢ãŒãã§ãã
ãŸãã¯ãä»ã®ããã°ã©ã ãŸãã¯ã¹ã¯ãªããå ããã®ãããåŠçããŒã«ãšããŠ:
$ eperl [ãªãã·ã§ã³] - < å ¥åãã¡ã€ã« > åºåãã¡ã€ã«
$ eperl [ãªãã·ã§ã³] å ¥åãã¡ã€ã« > åºåãã¡ã€ã«
$ eperl [ãªãã·ã§ã³] -o åºåãã¡ã€ã« - < å ¥åãã¡ã€ã«
$ eperl [ãªãã·ã§ã³] -o åºåãã¡ã€ã« å ¥åãã¡ã€ã«
ã芧ã®ãšãããePerl 㯠STDIO ãšå€éšãã¡ã€ã«ã®ä»»æã®çµã¿åããã§äœ¿çšã§ããŸãã
ããã«ããã®ã¢ãŒãã®äœ¿çšã«ã¯ XNUMX ã€ã®èå³æ·±ãããªãšãŒã·ã§ã³ããããŸãã ãŸã䜿çšã§ããŸã
ePerl ãš Unix ã®çµã¿åãã ã·ãã³ æé»çã«ãããéžæããéæ³ã®ãã¯ããã¯
ãã¬ãŒã³ãª Perl ã§æ £ããŠããæ¹æ³ãšåæ§ã®ã¹ã¯ãªããã®ã€ã³ã¿ãŒããªã¿
éèš³è ïŒ
#!/path/to/eperl [ãªãã·ã§ã³]
foo
<: "ããŒ" ãåºåããŸãã :>
ã¯ãã¯ã¹
XNUMX çªç®ã«ãePerl ã Bourne-Shell ãšçµã¿åãããŠäœ¿çšââã§ããŸãã ããã« ããã¥ã¡ã³ã æè¡
ã·ã§ã«ã¹ã¯ãªããå ãã:
#!/bin/sh
...
eperl [ãªãã·ã§ã³] - <
foo
<: "quux" ãå°å·ããŸãã :>
ã¯ãã¯ã¹
EOS
...
ePerl ã䜿çšããŠã·ã§ã«ãŸãã¯ä»ã®ã¹ã¯ãªãããçæããå¿ èŠãããå Žåãã€ãŸãã·ãã³ãå¿ èŠãªå Žå
eperl ã®åºåã«è¡ãããå Žåã¯ã次ã®ãããªã·ãã³è¡ãè¿œå ããå¿ èŠããããŸãã
ã#!/usr/bin/eperlããæåã§ããããã¯ãeperl ãå ¥åããæåã®è¡ãåé€ããããã§ãã
ã·ãã³ã©ã€ã³ã§ãã äŸïŒ
#!/usr/bin/eperl
#!/bin/sh
echo <: print "qux"; :>
çµæã¯æ¬¡ã®ãããªåºåã«ãªããŸãã
#!/bin/sh
ãšã³ãŒã»ã¯ãã¯ã¹
ãããã¯ã次ã®ããã«æåã®è¡ã«ããªããã»ããµã®ã³ã¡ã³ããè¿œå ããããšãã§ããŸãã
#c ããã¯æ¬¡ã®è¡ã®ã·ãã³è¡ãä¿åããããã®ã³ã¡ã³ãã§ã
#!/bin/sh
echo <: print "qux"; :>
ãããŠæåŸã«ã
解æ::ePerl(3) ããã±ãŒãž (ãããã€ã³ã¹ããŒã«ãããŠãããšä»®å®ããŸãããã¡ã€ã«ãåç §ããŠãã ãã) INSTALL
詳现ã«ã€ããŠã¯ãePerl ãã£ã¹ããªãã¥ãŒã·ã§ã³å ãåç §ããŠãã ãã):
#!/ãã¹/ãž/perl
...
Parse::ePerl ã䜿çšããŸãã
...
$script = <
foo
<: "quux" ãå°å·ããŸãã :>
ã¯ãã¯ã¹
EOT
...
$result = Parse::ePerl::Expand({
ã¹ã¯ãªãã => $script,
çµæ => \$çµæã
}ïŒ;
...
$çµæãå°å·ããŸãã
...
èŠã 解æ::ePerlïŒ3ïŒè©³çŽ°ã«ã€ããŠã¯ã
CGI / 1.1 æºæ ãã ã€ã³ã¿ãã§ãŒã¹ ã¢ãŒã
ããã¯ãePerl ã Web ãµãŒããŒã® CGI/1.1 ã€ã³ã¿ãŒãã§ã€ã¹ã䜿çšããã©ã³ã¿ã€ã ã¢ãŒãã§ãã
ãšããŠäœ¿çš ãµãŒãåŽ ã¹ã¯ãªããèšè¿° èšèª ãŠã§ãäžã§ã ePerl ã¯ãã®ã¢ãŒãã«å ¥ããŸã
CGI/1.1 ç°å¢å€æ°ãPATH_TRANSLATEDããèšå®ãããŠããå Žåã«èªåçã«
ãŸãã¯ã¹ã¯ãªããã®ãã¡ã€ã«åããããªããŸã NPH æ¥é èŸããã§å§ãŸããŸããããµïœâã ãã®ã©ã³ã¿ã€ã ã§ã¯
ã¢ãŒãã§ã¯ãçµæã®ããŒã¿ã« HTTP/1.0 (ããã©ã«ã) ãŸã㯠HTTP/1.1 (èå¥ãããŠããå Žå) ã®ãã¬ãã£ãã¯ã¹ãä»ããããŸãã
ãŠã§ããµãŒããŒã«ãã) ã«æºæ ããå¿çããããŒè¡ã
ePerl ã¯ãçæãããã¹ã¯ãªããã®å é ã«ãã HTTP ããããŒè¡ãèªèããŸãã
ããŒã¿ãã€ãŸããããšãã°æ¬¡ã®ãããªç¬èªã® HTTP ããããŒãçæã§ããŸãã
<? $url = "..";
print "å Žæ: $url\n";
print "URI: $url\n\n"; !>
...
ãã ããä»»æã®ããããŒãåºåã§ããäžæ¹ã§ãã»ãšãã©ã® Web ãµãŒããŒã§ã¯ããããŒã®åºåãå¶éãããŠããããšã«æ³šæããŠãã ããã
CGI/1.1 ã€ã³ã¿ãŒãã§ã€ã¹çµç±ã§åãå ¥ããããããããŒã éåžžãæäŸã§ããã®ã¯
ãLocationãããStatusããªã©ã®ç¹å®ã® HTTP ããããŒãããã€ããããŸãã ããã«å¶åŸ¡ãå¿ èŠãªå Žåã¯ã
NPH-CGI/1.1 ã€ã³ã¿ãŒãã§ã€ã¹ ã¢ãŒãã䜿çšããå¿ èŠããããŸãã
ããã«ãePerl ã¯ãã®ã¢ãŒãã§äŸ¿å©ãªæ©èœãæäŸããŸããUID/GID ãåãæ¿ããããšãã§ããŸãã
ã¹ã¯ãªããã Unix ãšããŠå®è¡ãããŠããå Žåã¯ããã®ã¹ã¯ãªããã®ææè ã«éä¿¡ãããŸãã ã»ããUID ããã°ã©ã (以äžãåç §)
ã»ãã¥ãªãã£ãšãªãã·ã§ã³ãu+sã chmodïŒ1ïŒïŒã
Web äžã§ãã® CGI/1.1 ã€ã³ã¿ãŒãã§ã€ã¹ ã¢ãŒãã䜿çšããäžè¬çã«ç¥ãããŠããæ¹æ³ã XNUMX ã€ãããŸãã
ãŸããããã䜿çšããŠãã¬ãŒã³ HTML ãã¡ã€ã«ã CGI/1.1 ã¹ã¯ãªããã«æ瀺çã«å€æã§ããŸãã
ã㢠ã·ãã³ ãã¯ããã¯ïŒäžèšãåç §ïŒã Apache WebãµãŒããŒã®å Žåã¯ã次ã®ããã«å ¥åããã ãã§ã
ãã¡ã€ã«ã®æåã®è¡ãšããŠæ¬¡ã®è¡ãè¿œå ããŸãã
#!/ãã¹/to/eperl -mc
次ã«ãã¹ã¯ãªããã®ååã次ããå€æŽããŸã ãã¡ã€ã«.html ããž ãã¡ã€ã«.cgi ãããŠãã®å®è¡ãããã次ã®ããã«èšå®ããŸã
$ mv ãã¡ã€ã«.html ãã¡ã€ã«.cgi
$ chmod a+rx ãã¡ã€ã«.cgi
次ã«ãApache ãåãå ¥ããããããšã確èªããŸãã ãã¡ã€ã«.cgi CGI ãµããŒããæå¹ã«ã㊠CGI ããã°ã©ã ãšããŠ
ãã£ã¬ã¯ããªã®å Žå ãã¡ã€ã«.cgi ãäœãã§ããã ãã®ããã«è¡ãè¿œå ããŸã
ãªãã·ã§ã³ +ExecCGI
ãã .htaccess ãã®ãã£ã¬ã¯ããªå ã®ãã¡ã€ã«ã æåŸã« Apache ãæ¬åœã«åäœããŠããããšã確èªããŸã
æ¡åŒµåãèªèããŸã .cgiã ãããã次ã®è¡ãè¿œå ããå¿ èŠããããŸã
ããªããž httpd.conf ãã¡ã€ã«ïŒ
AddHandler cgi-script .cgi
ä»ãã䜿çšã§ããŸã ãã¡ã€ã«.cgi ãã¡ã€ã«.html ãããŠéæããææã掻çšãã
åæ¯ã«ããããã°ã©ãã³ã°èœå ãã¡ã€ã«.cgi Perl ãããââ㯠(ãŸãã¯
CGI ã¹ã¯ãªãããžã®å€æã¯åœ¹ã«ç«ã¡ãŸãã)ã
ããã㯠(ãŸãã¯ããã«) ãŠã§ããã¹ã¿ãŒã¯ãããå€ãã®æ¹æ³ã§ ePerl ãµããŒããæå¹ã«ããããšãã§ããŸãã
ePerl ãå®éã®æé»çãªãµãŒããŒåŽã¹ã¯ãªããèšèªãšããŠæ§æããããšã«ãããã·ãŒã ã¬ã¹ãªæ¹æ³ã§å®çŸã§ããŸãã
ããã¯ãããŸããŸãªæå¹ãª ePerl ãã¡ã€ã«æ¡åŒµåã« MIME ã¿ã€ããå²ãåœãŠãããšã«ãã£ãŠè¡ãããŸãã
ãã® MIME ã¿ã€ããæã€ãã¹ãŠã®ãã¡ã€ã«ã ePerl çµç±ã§å éšåŠçãããããã«åŒ·å¶ããŸãã
éèš³è ã Apache ã§ãããå®çŸããã«ã¯ã次ã®ã³ãŒããè¿œå ããŸãã
httpd.conf file
AddType application/x-httpd-eperl .phtml .eperl .epl
ã¢ã¯ã·ã§ã³ application/x-httpd-eperl /internal/cgi/eperl
ScriptAlias /internal/cgi /path/to/apache/cgi-bin
ãããŠãã®ã³ããŒãäœæããŸã ããŒã« CGI ãã£ã¬ã¯ããªå ã®ããã°ã©ã :
$ cp -p /path/to/eperl /path/to/apache/cgi-bin/eperl
ããã§ãæ¡åŒµåãä»ãããã¹ãŠã®ãã¡ã€ã«ã .phtml, .eperl ãš .epl èªåçã«åŠçããã
ePerlã€ã³ã¿ããªã¿ã«ããã å¿ èŠã¯ãããŸãã ã·ãã³ åç·ãŸãã¯ããŒã«ã«ã§æå¹ãªä»»æã®åç·
CGIã¢ãŒãã
æåŸã®ãã³ã: ã¹ã¯ãªããããªãã©ã€ã³ã§ãã¹ãããå Žåã¯ã匷å¶çã«å®è¡ããŠãã ããã
ã·ã§ã«ãã CGI/1.1 ã¢ãŒããéžæããŸãã ãã ãããã¹ãŠã®ç°å¢å€æ°ãå¿ ãæºåããŠãã ããã
ã¹ã¯ãªããã¯ããQUERY_STRINGããŸãã¯ãPATH_INFOããªã©ã«äŸåããŸãã
$export QUERY_STRING="ããŒ1=å€1&ããŒ2=å€2"
$ eperl -mc ãã¡ã€ã«.phtml
NPH-CGI/1.1 æºæ ãã ã€ã³ã¿ãã§ãŒã¹ ã¢ãŒã
ãã®ã©ã³ã¿ã€ã ã¢ãŒãã¯ãCGI/1.1 ã€ã³ã¿ãŒãã§ã€ã¹ ã¢ãŒãã®ç¹æ®ãªããªã¢ã³ãã§ãã
Web ãµãŒã㌠(Apache ãªã©) ã¯ç¹å¥ãªç®çã®ããã«ãããæäŸããŸãã ãšããŠç¥ãããŠããŸã 解æãããŠããªã-
ããã (NPH) CGI/1.1 ã¢ãŒããéåžžããã¡ã€ã«åã次ã®å Žåã« Web ãµãŒããŒã«ãã£ãŠäœ¿çšãããŸãã
CGI ããã°ã©ã ã«ã¯ã"nph-"ããšããæ¥é èŸãä»ããŸãã ãã®ã¢ãŒãã§ã¯ãWeb ãµãŒããŒã¯äœãè¡ããŸããã
HTTP å¿çããããŒãåŠçããçµæã®ããŒã¿ããããã¡ãªã³ã°ããŸãããã€ãŸãã
å®éã«ã¯ãCGI ããã°ã©ã èªäœãå®å šãª HTTP å¿çãæäŸããå¿ èŠããããŸãã å©ç¹
ããã¯ãããã°ã©ã ãä»»æã® HTTP ããããŒãŸã㯠MIME ãšã³ã³ãŒãããããã«ããããã¯ãçæã§ããããšã§ãã
ã¡ãã»ãŒãžã
ãããã£ãŠãäžèšã§ã¯ãã¡ã€ã«ã®ååã次ã®ããã«å€æŽããŸãã ãã¡ã€ã«.cgi ãããç§ãã¡ãå°ãå¶éããŸããã ãã€
ãããã¯ååãå€æŽããŸã ãã¡ã€ã«.html ããž nph-ãã¡ã€ã«.cgi NPH-CGI/1.1 ã€ã³ã¿ãŒãã§ã€ã¹ã匷å¶ããŸã
ãªãã·ã§ã³ã«ããã¢ãŒã -å ãã®åŸããã®ãã¡ã€ã«ã¯ NPH-CGI/1.1 æºæ ã®ããã°ã©ã ã«ãªããŸãã
Apache ããã³ãã®ä»ã® Web ãµãŒããŒã ããã§ãã¹ã¯ãªããã¯ç¬èªã® HTTP å¿çãæäŸã§ããããã«ãªããŸãã (
ååšããªãå ŽåãePerl ãããã©ã«ãã®å€ãæäŸããããã§ã)ã
#!/ãã¹/to/bin/eperl -mn
<? ãHTTP/1.0 200 OK\nããå°å·ããŸãã
print "X-MyHeader: Foo Bar Quux\n";
print "ã³ã³ãã³ã ã¿ã€ã: text/html\n\n";
...
ãæ³åã®ãšãããããã¯æé»çãªãµãŒããŒãµã€ã ã¹ã¯ãªããèšèªã§ã䜿çšã§ããŸãã
æè¡ã 眮ã
AddType application/x-httpd-eperl .phtml .eperl .epl
ã¢ã¯ã·ã§ã³ application/x-httpd-eperl /internal/cgi/nph-eperl
ScriptAlias /internal/cgi /path/to/apache/cgi-bin
ããªãã« httpd.conf ã³ãã³ããå®è¡ããŸã
$ cp -p /path/to/eperl /path/to/apache/cgi-bin/nph-eperl
ããªãã®æ®»ããã ãã® is ã åªå æ¹æ³ of ePerl as a ãµãŒãåŽ ã¹ã¯ãªããèšè¿°
èšèªã ãªããªã it ã¯ã倧éªã§ æã æè»æ§.
ã»ãã¥ãªãã£
ePerl ã CGI/1.1 ãŸã㯠NPH-CGI/1.1 æºæ ããã°ã©ã ãšããŠã€ã³ã¹ããŒã«ããå Žå (äžèšãåç §)
ãããã®ã¢ãŒãã®è©³çŽ°ãªèª¬æ)
$ cp -p /path/to/eperl /path/to/apache/cgi-bin/eperl
$ chown root /path/to/apache/cgi-bin/eperl
$ chmod u+s /path/to/apache/cgi-bin/eperl
or
$ cp -p /path/to/eperl /path/to/apache/cgi-bin/nph-eperl
$ chown root /path/to/apache/cgi-bin/nph-eperl
$ chmod u+s /path/to/apache/cgi-bin/nph-eperl
ã€ãŸãã ã»ããUID ããããæå¹ã«ãªã£ãŠãã ã«ãŒã ãŠãŒã¶ãŒãePerl ã¯ããã® UID/GID ã«åãæ¿ããããšãã§ããŸãã
ã¹ã¯ãªãã ææè ã ããã¯ã¹ã¯ãªãã ããã°ã©ãã«ãšã£ãŠã¯éåžžã«äŸ¿å©ãªæ©èœã§ããã
è£å©ãã¡ã€ã«ã誰ã§ãèªã¿åããããã«ããããäžæãã¡ã€ã«ã誰ã§ãèªã¿åããããã«ãããããå¿ èŠããªããªããŸããã
æžã蟌ã¿å¯èœã§ã!)ãSetUID ã®ã»ãã¥ãªãã£ã«ã€ããŠåå·çã«ãªããšãéåžžã«å±éºã«ãªãå¯èœæ§ããããŸãã
ããã°ã©ã ã ãã®å Žåã¯ãSetUID ããããæå¹ã«ã㊠ePerl ãã€ã³ã¹ããŒã«ããªãã§ãã ããã ããããã®çç±ã§ã
ePerl ã¯ããã©ã«ãã§ã¹ã¿ã³ãã¢ãã³ Unix ãã£ã«ã¿ãšããŠã®ã¿ã€ã³ã¹ããŒã«ãããããããããå¿ èŠãšããŸãã
ç¹åŸŽã
ãã®æ©èœãèªåãã¡ã«ãšã£ãŠäžå¯æ¬ ã§ãããšå€æãã人ã®ããã«ãePerl ã¯å®éã«è©ŠããŠã¿ãŸãã
å®å šã«ããã®ã¯é£ããã ePerl ãå®è¡ããåã«ã次ã®æé ãæ£åžžã«å®äºããå¿ èŠããããŸãã
å®éã« UID/GID ã (ãã®é åºã§) åãæ¿ããŸãã
1. ã¹ã¯ãªããã¯æ¬¡ã®æ¡åŒµåãšäžèŽããå¿ èŠããããŸãã
.htmlã.phtmlã.ephtmlã.eplã.plã.cgi
2. åŒã³åºãããã»ã¹ã® UID ã¯æå¹ãª UID ã§ããå¿ èŠããããŸãã
ã€ãŸããã·ã¹ãã ã®ãã¹ã¯ãŒã ãã¡ã€ã«å ã§èŠã€ããå¿ èŠããããŸãã
3. åŒã³åºãããã»ã¹ã® UID ã¯ã
次ã®ãŠãŒã¶ãŒ: rootã誰ã
4. ã¹ã¯ãªããææè ã® UID ã¯æå¹ãª UID ã§ããå¿ èŠããããŸãã
ã€ãŸããã·ã¹ãã ã®ãã¹ã¯ãŒã ãã¡ã€ã«å ã§èŠã€ããå¿ èŠããããŸãã
5. ã¹ã¯ãªãã ã°ã«ãŒãã® GID ã¯æå¹ãª GID ã§ããå¿ èŠããããŸãã
ã€ãŸããã·ã¹ãã ã°ã«ãŒããã¡ã€ã«å ã§èŠã€ããå¿ èŠããããŸã
6. ã¹ã¯ãªããã¯ææè ã® homedir ã®äžãŸãã¯äžã«ååšããå¿ èŠããããŸãã
IF ãã£ãã® ONE OF ããã STEPS äžåæ Œã NO UID/GID ã¹ã€ããã³ã° åã å ŽæïŒã ããã«ïŒãã
ãDO_ON_FAILED_STEPãã¯ãSTOP_AND_ERRORããšããŠå®çŸ©ãããŸãã eperl_security.h - ããã©ã«ãã§ã¯ãããŸãã
ãã®ããã«å®çŸ©ãããŠããŸã!) ePerl ã¯åŠçãå®å šã«åæ¢ãããšã©ãŒ ããŒãžã衚瀺ããããšããããŸãã ããã¯
æ¬åœã«åå·çãªãŠã§ããã¹ã¿ãŒåãã ããããã®ã¹ããã㧠UID/GID åãæ¿ãã倱æããå Žåã®ããã©ã«ã
ã¯ç¡å¹ã«ãªã£ãŠããã ãã§ãããePerl ã¯åŠçãç¶è¡ããŸãã ãããã¯ãäžéšãç¡å¹ã«ããããšãã§ããŸã
ã³ã³ãã€ã«æã®ã¹ãããã èŠã eperl_security.h.
ãŸã èŠããŠããŸã ãã ePerl åžžã« æé€ ã å¹æç㪠UID/GIDã ç¬ç«ããŸãã of ã
ã©ã³ã¿ã€ã ã¢ãŒã ãš ç¬ç«ããŸãã if ePerl æã£ãŠããŸã åãæ¿ã ããž ã UID/GID of ã ãªãŒããŒã
ã»ãã¥ãªã㣠çç±ã ã å¹æç㪠UID/GID is åžžã« ç Žå£ããã ã ã¹ã¯ãªãã is å®è¡ãããŸããã
ePerl ããªããã»ããµ
ePerl ã¯ã次ã®ãããªç¬èªã®ããªããã»ããµãæäŸããŸãã CPP æå¹ã«ãªã£ãŠããã¹ã¿ã€ã«ã§
ãªãã·ã§ã³çµç±ã§æå㧠-P ãŸãã¯ãePerl ã (NPH-)CGI ã¢ãŒãã§å®è¡ããããšãã«èªåçã«å®è¡ãããŸãã 次ã®
ãã£ã¬ã¯ãã£ãããµããŒããããŠããŸãã
ã#ã€ã³ã¯ã«ãŒããã¹ã
ãã®ãã£ã¬ã¯ãã£ãã¯ãå®éã«ãããããã®ãã€ã³ã¯ã«ãŒãããããã«äœ¿çšã§ãã include ãã£ã¬ã¯ãã£ãã§ãã
ããããå®éã«ã¯ä»ã® ePerl ãœãŒã¹ ãã¡ã€ã«ãã€ã³ã¯ã«ãŒãããããã«äœ¿çšãããããã«èšèšãããŠããŸãã ã® path ã§ãã
ããŒã«ã« ãã¡ã€ã« ã·ã¹ãã ã®çžå¯Ÿãã¹ãŸãã¯çµ¶å¯Ÿãã¹ããŸãã¯å®å šä¿®é£Ÿãã¹ã®ããããã§ãã
HTTP URLã
絶察ãã¹ã®å Žåããã¡ã€ã«ã¯ãã¡ã€ã«ã·ã¹ãã äžã§çŽæ¥ã¢ã¯ã»ã¹ãããŸããã
çžå¯Ÿãã¹ã¯ããŸãçŸåšã®äœæ¥ãã£ã¬ã¯ããªå ã§æ€çŽ¢ããã次ã«ãã¹ãŠã®äœæ¥ãã£ã¬ã¯ããªå ã§æ€çŽ¢ãããŸãã
ãªãã·ã§ã³ã§æå®ããããã£ã¬ã¯ã㪠-Iã XNUMX çªç®ã®ã±ãŒã¹ (HTTP URL) ã§ã¯ããã¡ã€ã«ã¯æ¬¡ã®ããã«ãªããŸãã
ãããã¯ãŒã¯äžã® HTTP/1.0 ãªã¯ãšã¹ããä»ããŠååŸããŸãã ããã§ã¯ HTTP ãªãã€ã¬ã¯ã (å¿çã³ãŒã)
301 ããã³ 302) ããµããŒããããŠããŸãã
泚æ: ePerl ã¯åæ¯ã翻蚳ãããšãã«è¡çªå·ãå³å¯ã«ä¿æããŸããã
ePerl ãã©ãŒããããããã¬ãŒã³ Perl ãã©ãŒããããžã®å€æãePerl ããªããã»ããµã¯ãããè¡ãããšãã§ããŸãã (ePerl ããªããã»ããµã¯
ãã¬å±éããããã»ããµ) ããã®ãã£ã¬ã¯ãã£ãã«é©çšããŸãã ãããã£ãŠãã#includeãã䜿çšãããã³ã«ã
ãšã©ãŒ ã¡ãã»ãŒãžã®è¡çªå·ãééã£ãŠããããšã«æ³šæããŠãã ããã
ã»ãã¥ãªãã£äžã®éèŠãªåŽé¢ã«ã泚ç®ããŠãã ãããããã¯ããããããã®ããã®ãŸãŸå«ããããšãã§ããããã§ãã
ãã®ãã£ã¬ã¯ãã£ãã§æäŸããããã®ã¯ãããªãã®çŽäžã«ãããã®ã«ã®ã¿äœ¿çšããŠãã ãã
ã³ã³ãããŒã«ã ãã®ãã£ã¬ã¯ãã£ãã䜿çšããŠãå°ãªããšãå€éšããã®ããŒã¿ãå«ããªãã§ãã ããã
ãŠã§ããµãŒããŒã ããšãã°ãã#includeããå«ã ePerl ããŒãžããããšããŸãã
http://www.foreigner.com/nice-page.html" ãããŠããã®ããŒãžã®æ¬¡ã®ãªã¯ãšã¹ãã§ã
ãã¡ã€ã«ã·ã¹ãã ã倱ãããŸãã! ãªãïŒ å€åœäººã¯ããªããèªåã®ããŒãžãå«ããŠããããšãèªèããŠãããã
ePerl ã䜿çšããŠããŠãåçŽãªã"ããå ¥åããã ãã§ãã 圌ã®äžã®ãã
ããŒãžã èããŠã¿ãŠãã ããã è±èª USE ïŒå«ã FOR ANY DATA WHICH IS NOT ã¢ã³ããŒãŠã§ã¢ ãµãã©ã€ã€ ç¬èªã®
CONTROLã ãã®ãããªç¶æ³ã§ã¯ã代ããã«åžžã«ã#sincludeãã䜿çšããŠãã ããã
ã#sincludeãã¹ã
ããã¯ã#includeãã®å®å šãªããªã¢ã³ãã§ãããŒã¿ãèªã¿åã£ãåŸã path ã
ePerl ã®éå§åºåãæåãšçµäºåºåãæåã¯åé€ãããŸãã éåžžã«å±éºãª ePerl ãããââã¯ã¯æå³ã倱ã£ã
ãããŠãã¬ãŒã³ããã¹ãã«å€æãããŸãã ãå«ããå Žåã¯ãåžžã«ãã®ãã£ã¬ã¯ãã£ãã䜿çšããŠãã ããã
ããªãèªèº«ã®ç®¡çäžã«ãªãããŒã¿ã
ã#if exprããã#elsif exprããã#elseããã#endifã
ããã㯠CPP ã¹ã¿ã€ã«ã®ã#if-[#else-]#endifãæ§é ãå®è£ ããŸãããPerl ã»ãã³ãã£ã¯ã¹ã䜿çšããŸãã
ä»ã®ãã£ã¬ã¯ãã£ãã¯å®éã®ããªããã»ããµ ã³ãã³ãã§ããã
ååŠçã¹ãããã§ã¯ããã®æ§é ã¯å®éã«ã¯äœã¬ãã«ã® ePerl ã«å€æãããã ãã§ãã
æ§ç¯ããŠãã ãã å®éã«ååŠçã¹ãããã§è©äŸ¡ãããŸãã ããã¯ãã ã®
以äžã®äŸ¿å©ãªã·ã§ãŒãã«ãã (BD ã¯çŸåšäœ¿çšãããŠããéå§åºåãæåã§ããã
ED ã¯çµäºåºåãæå):
ã#if exprã -> ãBD if (expr) { _ ED//ã
ã#elsif exprã -> ãBD } elsif (expr) { _ ED//ã
ã#elseã -> ãBD } else { _ ED//ã
ã#endifã -> ãBD } _ ED//ã
ãã®çããã¢ãããŒãã®å©ç¹ã¯ãif æ¡ä»¶ãå®éã«æå¹ãªä»»æã®æ¡ä»¶ã«ã§ããããšã§ãã
æ倧éã®æè»æ§ãæäŸãã Perl åŒã æ¬ ç¹ã¯ãããªãã
if-construct ã䜿çšããŠå®éã®ååŠçã®æ±ºå®ãè¡ãããšã¯ã§ããŸããã ã芧ã®ãšããã
èšèšç®æšã¯ãããè€é㪠Perl æ§é ã®çç¥è¡šçŸãæäŸããããšã ãã§ããã
ã#cã
ããã¯ãã³ã¡ã³ã ãã£ã¬ã¯ãã£ãã§ãããããŸã§ã®ãã¹ãŠã®ããŒã¿ãç Žæ£ããŸãã
æ¹è¡æåã ããã䜿çšããŠãä»ã®ããªããã»ããµãå«ããŠãããããã®ãã³ã¡ã³ãã¢ãŠãããŸãã
ãã£ã¬ã¯ãã£ã
æäŸ Functionality
ãããŸã§ã§ãePerl ã«ã¯ Perl ã³ãŒããåã蟌ãåªããæ©èœãåãã£ãŠããããšãç解ã§ãããšæããŸãã
ä»»æã® ASCII ããŒã¿ã ãããããã§ã®å žåçãªè³ªåã¯ãã©ã® Perl ã³ãŒãããããã«å«ããããšãã§ããããšããããšã§ãã
ePerl ã¯ãããã¯ããŸãããePerl ã¯ãããã® ePerl ãããââã¯å ã§ç¹å¥ãªæ©èœãæäŸããŸãã?
çãã¯æ¬¡ã®ãšããã§ãããŸããå®éã« ã©ãã Perl ã³ãŒãã ePerl ãããââã¯ã«æ¿å ¥ããŸãã
ePerl ããªã³ã¯ããã Perl ã€ã³ã¿ããªã¿ã«å¯ŸããŠæå¹ã§ãã 第äºã«ãePerl ã¯æ¬¡ã®ããšãè¡ããŸãã äœããæäŸãã
Perl ã¯ãã§ã«æŽç·ŽãããŠããããããããã® ePerl ãããââã¯å ã®ç¹å¥ãªæ©èœ
åå ;-ïŒ
ãã®ããšã®æå³ã¯æ¬¡ã®ãšããã§ããæå¹ãª Perl ã³ãŒãã䜿çšã§ããããã
å ±æãªããžã§ã¯ãã䜿çšããã¢ãžã¥ãŒã«ãå«ããŠãå©çšå¯èœãªãã¹ãŠã® Perl 5 ã¢ãžã¥ãŒã« (ePerl ã§ãããã) is a
Perl ã€ã³ã¿ãŒããªã¿ãŒ (DynaLoader ãµããŒããå«ã)ã ããã§ãç·å Perl ãåç §ããŠãã ããã
ã¢ãŒã«ã€ã ãããã¯ãŒã¯ (CPAN) çµç± http://www.perl.com/perl/CPAN ãæ°ã«å ¥ãã®ããã±ãŒãžãå ¥æããŠãã ãã
ããã«ãããäœæ¥ã楜ã«ãªããŸã (ã©ã¡ãããã¬ãŒã³ãª Perl ã¹ã¯ãªããå ãã) ãš ePerl ã¹ã¯ãªãã)
ãããŠãä»»æã® ePerl ãããââã¯å ã§æ§æäœ ``"use name;"'' ã䜿çšããã ãã§ãå éšãããããã䜿çšã§ããŸãã
ePerlã
ePerl ããµãŒããŒãµã€ãã¹ã¯ãªããèšèªãšããŠäœ¿çšããå Žåã¯ã次ã®å Žæã«ã€ã³ã¹ããŒã«ããããšã匷ããå§ãããŸãã
å°ãªããšãããã±ãŒãžã¯ CGI.pm (çŸåšããŒãžã§ã³ 2.36)ã HTMLã¹ããªãŒã ïŒ1.40ïŒ ãªãããã ïŒ1.0505ïŒãš
libwww-perl (5.08)ã ãªã³ã¶ãã©ã€ç»åãçæãããå Žåã¯ã
å°ãªããšãè¿œå ã§ã€ã³ã¹ããŒã«ããã«ã¯ GD ïŒ1.14ïŒãš ç»åãµã€ãº (2.3)ã ePerl ã€ã³ã¿ãŒããªã¿
ãããã®éåžžã«æŽç·Žããã Perl 5 ã¢ãžã¥ãŒã«ãšçµã¿åãããããšã§ãæ倧éã®æ©èœãæäŸãããŸãã
æè»æ§ãšæ©èœæ§ã èšãæãããšïŒ ã¢ã«ãŠã³ããäœæã ã€ãããŸã of ãœãããŠã§ã¢ 掻çšããŸã in
ã ããã«ãŒ äžç of ããŒã« as çŽ æŽããã as å¯èœ.
OPTIONS
-d å=å€
$name ãŸãã¯ãã以äžãä»ããŠåç §ã§ããããã±ãŒãžãmainãã« Perl å€æ°ãèšå®ããŸãã
$main::name çµç±ã§æ瀺çã«ã ã³ãã³ã
eperl -d åå=å€ ..
å®éã«ã¯ã
ã®åé å ¥åãã¡ã€ã«ã ãã®ãªãã·ã§ã³ã¯è€æ°åå®è¡ã§ããŸãã
-D å=å€
å éšã® $ENV{'variable'} çµç±ã§åç §ã§ããç°å¢å€æ°ãèšå®ããŸãã
Perl ãããââã¯ã ã³ãã³ã
eperl -D åå=å€ ..
å®éã«ã¯ãšåçã§ã
ãšã¯ã¹ããŒãå=å€; ãšããŒã« ...
ãã ãããã®ãªãã·ã§ã³ã®å©ç¹ã¯ãåŒã³åºãå ãæäœããªãããšã§ãã
ç°å¢ã ãã®ãªãã·ã§ã³ã¯è€æ°åçºçããå¯èœæ§ããããŸãã
-B begin_delimiter
Perl ãããââã¯ã®éå§åºåãæååãèšå®ããŸãã ãããã-Eããšçµã¿åãããŠäœ¿çšââããŠèšå®ããŸãã
ePerl ããªãã©ã€ã³ HTML äœæèšèªãšããŠäœ¿çšããå Žåã®ç°ãªãåºåãæå
ãªã³ã©ã€ã³ã® HTML ã¹ã¯ãªããèšèªãšããŠäœ¿çšããŸãã ããã©ã«ãã®åºåãæåã¯ããã§ãã ã
CGI ã¢ãŒãã®å Žåã¯ã<:ããšã:>ããã¹ã¿ã³ãã¢ãã³ Unix ãã£ã«ã¿ãªã³ã° ã¢ãŒãã®å Žåã§ãã
éžæã§ããããªãšãŒã·ã§ã³ã¯å€æ°ãããŸããã"<:"" ãš "":>"ã(
ããã©ã«ãã® ePerl ã¹ã¿ã³ãã¢ãã³ ãã£ã«ã¿ãªã³ã° ã¢ãŒãåºåãæå)ã"" "" ïŒããã©ã«ã
ePerl CGI ã€ã³ã¿ãŒãã§ã€ã¹ ã¢ãŒãåºåãæå)ã"" "" and "" ãã
(æšæºã® HTML ã¹ã¯ãªããèšèªã¹ã¿ã€ã«)ã"" "" and
ãã "" (ä»åŸã® HTML3.2+ å¥å Cougar ã¹ã¿ã€ã«)ã"" "" ãã㊠"" ãã
(HTML 颚ã®ã¹ã¿ã€ã«)ããã "" (NeoScript ããã³ SSI ã¹ã¿ã€ã«) ãŸãã¯
å¹³ "" "" (PHP/FI ã¹ã¿ã€ã«ããã ããããã¯æšå¥šãããªããªããŸããã
解æã®åé¡ã«ã€ãªãããŸãã å€ã ePerl ãšã®äžäœäºææ§ã®ããã«ã®ã¿äœ¿çšããå¿ èŠããããŸãã
ããŒãžã§ã³ 1.x)ã
éå§åºåãæåãšçµäºåºåãæåã¯ã倧æåãšå°æåãåºå¥ããã«æ€çŽ¢ãããŸãã
-E çµäºåºåãæå
Perl ãããââã¯ã®çµäºåºåãæååãèšå®ããŸãã ãªãã·ã§ã³ãåç §ããŠãã ãã -B.
-i éå§åºåãæåãšçµäºåºåãæåã倧æåãšå°æåãåºå¥ããã«æ€çŽ¢ãããããã«åŒ·å¶ããŸãã ãããªãšãã«äœ¿ããŸã
ããã®ãããªåºåãæåã䜿çšããŠããŸãã ã...ã "" ãŸãã¯ãã®ä»ã®ããããã¹ãçãªãã®ã
-m ã¢ãŒã
ããã«ãããePerl ã¯ç¹å®ã®ã©ã³ã¿ã€ã ã¢ãŒãã§åäœããããã«ãªããŸãã 詳现ã«ã€ããŠã¯äžèšãåç §ããŠãã ãã
å¯èœãª XNUMX ã€ã®ã¢ãŒãã®èª¬æ: ã¹ã¿ã³ãã¢ãã³ ãã£ã«ã¿ãŒ (ã¢ãŒã="f"ãã€ãŸããªãã·ã§ã³
-mf)ãCGI/1.1 ã€ã³ã¿ãŒãã§ã€ã¹ ã¢ãŒã (ã¢ãŒã="c"ãã€ãŸããªãã·ã§ã³ -mc) ãŸã㯠NPH-CGI/1.1 ã€ã³ã¿ãŒãã§ã€ã¹
ã¢ãŒãïŒã¢ãŒã="n"ãã€ãŸããªãã·ã§ã³ -å).
-o åºåãã¡ã€ã«
åºåã匷å¶çã«æžã蟌ã åºåãã¡ã€ã« æšæºåºåã ãã®ãªãã·ã§ã³ã¯æ¬¡ã®å Žåã«äœ¿çšããŸãã
ePerlããã£ã«ã¿ãšããŠäœ¿çšããŸãã åºåãã¡ã€ã«ã-'' ã»ãã æšæºåºå åºåãã³ãã«ãšããŠ
æ瀺çã«ã ãã®ãã¡ã€ã«ã¯ããœãŒã¹ ãã¡ã€ã« ãã£ã¬ã¯ããªã«çžå¯ŸããŠããããšã«æ³šæããŠãã ããã
ã©ã³ã¿ã€ã ã¢ãŒã㯠CGI ãŸã㯠NPH-CGI ã«åŒ·å¶ãããŸãã
-k ePerl ãèµ·åãããå ŽæããçŸåšã®äœæ¥ãã£ã¬ã¯ããªãä¿æããããã«åŒ·å¶ããŸãã åœãã
ããã©ã«ãã® ePerl ã¯ãå®è¡ããããã¡ã€ã«ãååšãããã£ã¬ã¯ããªã«å€æŽãããŸãã ãã
ãã®ãªãã·ã§ã³ã¯ãePerl ãäžæãã¡ã€ã«ã®ãªãã©ã€ã³ ãã£ã«ã¿ãŒãšããŠäœ¿çšããå Žåã«äŸ¿å©ã§ãã
-x ããã«ãããePerl ãå éšã§äœæããã Perl ã¹ã¯ãªãããåºåãããããã° ã¢ãŒããèšå®ãããŸãã
ã³ã³ãœãŒã« ïŒ/ dev / tty) å®è¡ããåã«ã å ¥åãã¡ã€ã«ã«é¢ããåé¡ã®ãããã°ã®ã¿
å€æã
-I ãã£ã¬ã¯ããªã«ãžã§ããéå§ããŸãã
ã#includeããã£ã¬ã¯ãã£ããšã#sincludeããã£ã¬ã¯ãã£ãã®äž¡æ¹ã«äœ¿çšããããã£ã¬ã¯ããªãæå®ããŸãã
ePerl ããªããã»ããµã§ãããå®è¡æã« @INC ã«è¿œå ãããŸãã ãã®ãªãã·ã§ã³ã¯ããã«çºçããå¯èœæ§ããããŸã
äžåºŠããã
-P ç¹å¥ãª ePerl ããªããã»ããµãæåã§æå¹ã«ããŸã (äžèšãåç §)ã ãã®ãªãã·ã§ã³ã¯æå¹ã«ãªã£ãŠããŸã
ãã¹ãŠã® CGI ã¢ãŒãã«èªåçã«é©çšãããŸãã
-C ããã«ãããePerl ãããââã¯ã® HTML ãšã³ãã£ãã£å€æãæå¹ã«ãªããŸãã ãã®ãªãã·ã§ã³ã¯èªåçã«
CGI ã¢ãŒãã§ã¯åŒ·å¶ãããŸãã
ããã§è§£æ±ºãããåé¡ã¯æ¬¡ã®ãšããã§ãã ePerl ããµãŒããŒåŽãšããŠäœ¿çšããå Žåã
HTML ããŒãžçšã®ã¹ã¯ãªããèšèªãHTML çµç±ã§ ePerl ãœãŒã¹ ãã¡ã€ã«ãç·šéããŸãã
ãšãã£ã¿ãŒã®å Žåããšãã£ã¿ãŒãå ¥åãããæåã®äžéšã HTML ã«å€æããå¯èœæ§ãé«ããªããŸãã
ãšã³ãã£ãã£ãããšãã°ã"<"ãããã"<"ãã ããã«ãããå éšã«ç¡å¹ãª Perl ã³ãŒããçºçããŸã
ePerl ãããââã¯ãHTML ãšãã£ã¿ãŒã¯ ePerl ãããââã¯ã«é¢ããç¥èãæã£ãŠããªãããã§ãã ããã䜿ããš
ãªãã·ã§ã³ã§ã¯ãePerl ããŒãµãŒã¯ ePerl ãããââã¯å ã§èŠã€ãã£ããã¹ãŠã®ãšã³ãã£ãã£ãèªåçã«å€æããŸã
ãã¬ãŒã³æåã«æ»ãã®ã§ãPerl ã€ã³ã¿ããªã¿ã¯åã³æå¹ãªã³ãŒã ãããã¯ãåãåããŸãã
-L ããã«ãããePerl ãããââã¯ã®å€åŽã§è¡ç¶ç¶æåã"\"ãïŒããã¯ã¹ã©ãã·ã¥ïŒãæå¹ã«ãªããŸãã
ãã®ãªãã·ã§ã³ã䜿çšãããšãXNUMX è¡ã®ããŒã¿ãè€æ°ã®è¡ã«åæ£ã§ããŸãã ãã ãã泚æããŠäœ¿çšããŠãã ããã
ãªãã·ã§ã³ã¯ããŒã¿ (ePerl ãããââã¯ã®å€åŽ) ãå€æŽããŸãã éåžžãePerl ã¯å®éã«ééããŸã
åšå²ã®ãã¹ãŠã®ããŒã¿ãçããŒã¿ãšããŠä¿åããŸãã ãã®ãªãã·ã§ã³ã䜿çšãããšãæ¹è¡ãæ°ããã»ãã³ãã£ã¯ã¹ã«ãªããŸãã
-T ããã«ãã Perl ãæå¹ã«ãªããŸãã æ±æ ã¢ãŒã Perl ã€ã³ã¿ããªã¿ãç¹å¥ãªäºé²æªçœ®ãè¬ããå Žå
æãããªãã©ãããšåŸ®åŠãªãã©ããã®äž¡æ¹ãé²ãããã«ãæ±æãã§ãã¯ãšåŒã°ããŸãã èŠã ããŒã«ã»ãã¯ïŒ1ïŒè©³çŽ°
詳现ã
-w ããã«ãããPerl ã€ã³ã¿ãŒããªã¿ãŒãçŽ æµãªèšºæãçæããèŠåãæå¹ã«ãªããŸãã èŠã
ããŒã«ãã£ã¢ã°ïŒ1ïŒè©³çŽ°ã«ã€ããŠã¯ã
-c ããã«ããããperl -cããšåæ§ã®çŽç²ãªæ§æãã§ãã¯ãå®è¡ãããŸãã
-r ããã«ãããå éš ePerl README ãã¡ã€ã«ãã³ã³ãœãŒã«ã«åºåãããŸãã
-l ããã«ãããå éš ePerl LICENSE ãã¡ã€ã«ãã³ã³ãœãŒã«ã«åºåãããŸãã
-v ããã«ãããePerl ã®ããŒãžã§ã³æ å ±ãã³ã³ãœãŒã«ã«åºåãããŸãã
-V ãªãã·ã§ã³ãšåã -v ãã ããPerl ã³ã³ãã€ã« ãã©ã¡ãŒã¿ãŒãè¿œå ã§è¡šç€ºãããŸãã
ENVIRONMENT
äžå€ Variables
ãPATH_TRANSLATEDã
ãã® CGI/1.1 å€æ°ã¯ãePerl ããšããŠåäœãããšãã«ãœãŒã¹ ãã¡ã€ã«ã決å®ããããã«äœ¿çšãããŸãã
WebãµãŒããŒç°å¢äžã®NPH-CGI/1.1ããã°ã©ã ã
æäŸ Variables
ãSCRIPT_SRC_PATHã
ã¹ã¯ãªããã®çµ¶å¯Ÿãã¹åã çŽæ¥ã¢ã¯ã»ã¹ãããå Žåã«äœ¿çšããŸãã
ããšãã°ããstat()ãããã®ä»ã®åŒã³åºããå®è¡ããããã®ã¹ã¯ãªããã§ãã
ãSCRIPT_SRC_PATH_DIRã
ãSCRIPT_SRC_PATHãã®ãã£ã¬ã¯ããªéšåã çŽæ¥ã¢ã¯ã»ã¹ãããå Žåã¯ãã¡ãããå©çšãã ããã
ã¹ã¯ãªãããšåããã£ã¬ã¯ããªã«ããä»ã®ãã¡ã€ã« (æ§æãèªã¿åããããªã©)
ãã¡ã€ã«ãªã©
ãSCRIPT_SRC_PATH_FILEã
ãSCRIPT_SRC_PATHãã®ãã¡ã€ã«åéšåã ã®ååãââå¿ èŠãªå Žåã«ããã䜿çšããŸãã
ããšãã°ãURL ãä»ããçžå¯Ÿçãªèªå·±åç §çšã®ã¹ã¯ãªããã
ãSCRIPT_SRC_URLã
ã¹ã¯ãªããã®å®å šä¿®é£Ÿ URLã èªåèªèº«ã® URL ãå¿ èŠãªå Žåã«ããã䜿çšããŸãã
åç §ã
ãSCRIPT_SRC_URL_DIRã
ãSCRIPT_SRC_URLãã®ãã£ã¬ã¯ããªéšåã çŽæ¥ã¢ã¯ã»ã¹ãããå Žåã¯ãã¡ãããå©çšãã ããã
Web çµç±ã§ã¹ã¯ãªãããšåããã£ã¬ã¯ããªã«ããä»ã®ãã¡ã€ã«ãããšãã°ã
åèç»åãªã©
ãSCRIPT_SRC_URL_FILEã
ãSCRIPT_SRC_URLãã®ãã¡ã€ã«åéšåã ã®ååãââå¿ èŠãªå Žåã«ããã䜿çšããŸãã
ããšãã°ãURL ãä»ããçžå¯Ÿçãªèªå·±åç §çšã®ã¹ã¯ãªããã å®ã¯åã
ãSCRIPT_SRC_PATH_FILEãã§ãããäžè²«æ§ã®ããã«æäŸãããŠããŸãã
ãSCRIPT_SRC_SIZEã
ã¹ã¯ãªããã®ãã¡ã€ã«ãµã€ãº (ãã€ãåäœ)ã
ãSCRIPT_SRC_MODIFIEDã
ã¹ã¯ãªããã®æçµå€æŽæå» (0 æé 0 å 0 ããã®ç§æ°)
ç§ã1 幎 1970 æ XNUMX æ¥ãåå®äžçæã
ãSCRIPT_SRC_MODIFIED_CTIMEã
ã¹ã¯ãªããã®æçµå€æŽæå» (åäœ: ctime(3) åœ¢åŒ (``WDAY MMM DD HH:MM:SS
YYYY\n'')ã
ãSCRIPT_SRC_MODIFIED_ISOTIMEã
ã¹ã¯ãªããã®æçµå€æŽæå» (ISO åœ¢åŒ (``DD-MM-YYYY HH:MM''))ã
ãSCRIPT_SRC_OWNERã
ã¹ã¯ãªããææè ã®ãŠãŒã¶ãŒåã
ãVERSION_INTERPRETERã
ePerl èå¥æååã
ãVERSION_LANGUAGEã
䜿çšããã Perl ã€ã³ã¿ããªã¿ ã©ã€ãã©ãªã®èå¥æååã
æäŸ å èµ ç»å
次ã®çµã¿èŸŒã¿ã€ã¡ãŒãžã«ã¯ãURLã/url/to/nph-eperl/ãçµç±ã§ã¢ã¯ã»ã¹ã§ããŸããNAME".gif":
ãããŽ.gifã
æšæºã® ePerl ããŽã ãããããªãã®ãŠã§ããµã€ãã«å«ããªãã§ãã ããã
ãpowered.gifã
ãããã¯ãŒã by ePerl 2.2ãã®ããŽã ããªãã®ãŠã§ããµã€ãã§ãèªç±ã«ã䜿ããã ããã
onworks.net ãµãŒãã¹ã䜿çšããŠãªã³ã©ã€ã³ã§ eperl ã䜿çšãã