ÆüËܸì perl texinfo


ÆüËܸì perl texinfo ¤Ë¤Ä¤¤¤Æ

ÆüËܸì perl texinfo ¥Ð¡¼¥¸¥ç¥ó 4.035.1

¤³¤ÎÆüËܸì perl texinfo ¤Ï¡¢ ´ðËÜŪ¤Ë perl 4.0 ¥Ñ¥Ã¥Á¥ì¥Ù¥ë 35 ¤Î¥ª¥ó¥é¥¤¥ó¥Þ¥Ë¥å¥¢¥ë¤òÆüËܸìÌõ¤·¡¢ ¤½¤Î¥»¥¯¥·¥ç¥óʬ¤±¤ËÂбþ¤·¤¿¥Î¡¼¥É¤Ëʬ³ä¤·¤¿¤â¤Î¤Ç¤¹¡£ ´Ø¿ô¤ÎÀâÌÀ¤Î¥Î¡¼¥É¤Ê¤É¡¢Ä¹¤¹¤®¤ë¤ÈȽÃǤ·¤¿¥Î¡¼¥É¤Ï¡¢ »ä¤¬¾¡¼ê¤Ëʬ³ä¤·¤Þ¤·¤¿¡£¤Ê¤ª¡¢´Ø¿ô¤ÎʬÎà¤Ë¤Ï¡¢ comp.lang.perl ¤Ëή¤ì¤Æ¤¤¤¿ `Perl Reference Guide' ¤ò»²¹Í¤Ë¤·¤Þ¤·¤¿¡£

¤´Í÷¤Ë¤Ê¤ì¤Ð¤ª¤ï¤«¤ê¤Î¤è¤¦¤Ë¡¢¤¢¤Á¤³¤Á¤Ë ? ¥Þ¡¼¥¯¤ä¸¶Ê¸¤Î°úÍѤ¬¤¢¤ê¤Þ¤¹¡£ ¤³¤ì¤Ï¡¢»ä¤¬ÆüËܸì¤ËÌõ¤»¤Ê¤«¤Ã¤¿¤ê¡¢¼«¿®¤¬¤Ê¤«¤Ã¤¿¤ê¡¢ Ìõ¤»¤Æ¤â°ÕÌ£¤¬Ê¬¤«¤é¤Ê¤«¤Ã¤¿¤ê¤·¤¿¤â¤Î¤Ç¤¹¡£ ¤´Í÷¤Î³§Íͤ¬¤³¤ì¤é¤ò°ì¤Ä¤Ç¤â¸º¤é¤¹¤³¤È¤Ë¤´¶¨ÎϤ¤¤¿¤À¤±¤ì¤ÐÈó¾ï¤Ë¹¬¤¤¤Ç¤¹¡£

¤Þ¤¿¡¢ÆüËܸìÌõ¤Ë¤¢¤¿¤Ã¤Æ¤Ï¡¢¤¿¤È¤¨ÆüËܸì¤È¤·¤Æ¤Þ¤º¤¯¤Æ¤â µ»½ÑŪ¤Ë´Ö°ã¤Ã¤Æ¤¤¤Ê¤¤Ìõ¤òÌܻؤ·¤¿¤Ä¤â¤ê¤Ç¤¹¤¬¡¢ »ä¤¬ UNIX ¤ò¿¼¤¯Íý²ò¤·¤Æ¤¤¤Ê¤¤¤³¤È¤«¤é¤¯¤ë´ª°ã¤¤¤â¤¢¤ë¤È»×¤¤¤Þ¤¹¡£ ¤³¤ÎÅÀ¤â»ØŦ¤¤¤¿¤À¤±¤ì¤Ð¹¬¤¤¤Ç¤¹¡£

¤Ç¤Ï¡¢perl life ¤ò¤ª³Ú¤·¤ß²¼¤µ¤¤¡£

(Êä­¤½¤Î1)
`Perl Reference Guide' ¤Îºî¼Ô¤Ï jv@mh.nl ¤Ç¤¹¡£ ºÇ¿·ÈÇ¤Ï Perl 4.0 patchlevel 19 ¤ËÂбþ¤·¤Æ¤¤¤Þ¤¹¡£ comp.lang.perl ¤Ë¥Ý¥¹¥È¤µ¤ì¤¿»þ¤Î¥á¥Ã¥»¡¼¥¸ID¤ò°Ê²¼¤Ë¼¨¤·¤Þ¤¹¡£

<1992Feb19.153340.15645@pronto.mh.nl> (PostScript ¥­¥Ã¥È part 0 of 4)
<1992Feb19.153749.15960@pronto.mh.nl> (PostScript ¥­¥Ã¥È part 1 of 4)
<1992Feb19.153823.16023@pronto.mh.nl> (PostScript ¥­¥Ã¥È part 2 of 4)
<1992Feb19.153855.16086@pronto.mh.nl> (PostScript ¥­¥Ã¥È part 3 of 4)
<1992Feb19.153936.16149@pronto.mh.nl> (PostScript ¥­¥Ã¥È part 4 of 4)
<1992Feb19.153425.15708@pronto.mh.nl> (LaTex ¥­¥Ã¥È part 0 of 3)
<1992Feb19.153528.15771@pronto.mh.nl> (LaTex ¥­¥Ã¥È part 1 of 3)
<1992Feb19.153607.15834@pronto.mh.nl> (LaTex ¥­¥Ã¥È part 2 of 3)
<1992Feb19.153702.15897@pronto.mh.nl> (LaTex ¥­¥Ã¥È part 3 of 3)

(Êä­¤½¤Î2)
comp.lang.perl ¤Ë¤ª¤¤¤Æ¤Ï±Ñ¸ìÈÇ texinfo ¤Î¥¢¥Ê¥¦¥ó¥¹¤â¥Ý¥¹¥È¤µ¤ì¤Æ¤¤¤Þ¤¹¤¬¡¢ ¤³¤ÎÆüËܸì perl texinfo ¤Ï¤½¤ì¤È¤ÏÆÈΩ¤ËºîÀ®¤·¤¿¤â¤Î¤Ç¤¢¤ê¡¢ ²¿¤Î´Ø·¸¤â¤¢¤ê¤Þ¤»¤ó¡£¼ÂºÝ¡¢¥»¥¯¥·¥ç¥óʬ¤±¡¦´Ø¿ô¤ÎʬÎà¤Ê¤É¤¬°Û¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£ ±Ñ¸ìÈÇ texinfo ¤Ï ftp.dreams.org:/pub/perl-manual ¤«¤é ftp ¤Ç¤­¤Þ¤¹¤·¡¢ ¹ñÆâ¤Î FTP ¥µ¥¤¥È¤Ë¤â¥¢¡¼¥«¥¤¥Ö¤µ¤ì¤Æ¤¤¤Þ¤¹¡£ ºÇ¿·ÈÇ¤Ï Perl 4.0 patchlevel 19 ¤ËÂбþ¤·¤Æ¤¤¤Þ¤¹¡£

ºÇ¿·ÈǤϤ¤¤º¤ì¤â 92ǯ11·î21Æü¤Ë³Îǧ¤·¤Þ¤·¤¿¡£

perl ¤È¤Ï²¿¤«?

perl -- Practical Extraction and Report Language

(Ãê½Ð & Êó¹ðÍѼÂÍÑŪ¸À¸ì)

»È¤¤Êý : perl [¥ª¥×¥·¥ç¥ó] ¥Õ¥¡¥¤¥ë̾ °ú¿ô

perl ¤ÏǤ°Õ¤Î¥Æ¥­¥¹¥È¥Õ¥¡¥¤¥ë¤ÎÁöºº¡¢¥Æ¥­¥¹¥È¥Õ¥¡¥¤¥ë¤«¤é¤Î¾ðÊó¤Î¼è¤ê½Ð¤·¡¢ ¤½¤Î¾ðÊó¤Ë´ð¤Å¤¤¤¿¥ì¥Ý¡¼¥È¤Î½ÐÎϤΤ¿¤á¤ËºÇŬ²½¤µ¤ì¤¿¥¤¥ó¥¿¡¼¥×¥ê¥¿¸À¸ì¤Ç¤¢¤ë¡£ ¤Þ¤¿¡¢¥·¥¹¥Æ¥à´ÉÍýºî¶È¤Î¿¤¯¤ËŬ¤·¤¿¸À¸ì¤Ç¤â¤¢¤ë¡£ perl ¤ÏÈþ¤·¤¤(¾®¤µ¤¤¡¢¥¨¥ì¥¬¥ó¥È¡¢ºÇ¾®)¤È¤¤¤¦¤è¤ê¤Ï ¼ÂÍÑŪ(»È¤¤¤ä¤¹¤¤¡¢¸úΨŪ¡¢´°Á´)¤Ç¤¢¤ë¡£

perl ¤Ï C¡¢sed¡¢awk¡¢sh ¤Î ºÇ¤â¤è¤¤¤È¤³¤í¤ò·ë¹ç¤·¤¿¤â¤Î¤Ç¤¢¤ë(ºî¼Ô¤Î°Õ¸þ¤È¤·¤Æ¤Ï¡¢¤Ç¤¢¤ë¤¬)¤Î¤Ç¡¢ ¤³¤ì¤é¤Î¸À¸ì¤Ë¤Ê¤¸¤ß¤Î¤¢¤ë¿Í¤Ê¤é¤Ð perl ¤ò»È¤¦¤Î¤ÏÍưפǤ¢¤í¤¦¡£ (¸À¸ìÎò»Ë³Ø¼Ô¤Ê¤é csh¡¢Pascal¡¢¤µ¤é¤Ë¤Ï BASIC-PLUS ¤Îº¯Àפ˵¤¤¬¤Ä¤¯¤À¤í¤¦¡£) ɽ¸½Ë¡¤Ï C ¤Îɽ¸½Ë¡¤Ë¤½¤Ã¤¯¤ê¤Ç¤¢¤ë¡£

ÂçȾ¤Î UNIX ¤Î¥æ¡¼¥Æ¥£¥ê¥Æ¥£¤È¤Ï°ã¤¤¡¢ perl ¤Ï¥Ç¡¼¥¿¤Î¥µ¥¤¥º¤òÀ©¸Â¤·¤Ê¤¤ -- ¥á¥â¥ê¤¬¤¢¤ë¤«¤®¤ê¡£ perl ¤Ï¥Õ¥¡¥¤¥ëÁ´ÂΤò°ì¤Ä¤Îʸ»úÎó¤È¤·¤ÆÆɤ߹þ¤à¤³¤È¤¬¤Ç¤­¤ë¡£ ºÆµ¢¤Î¿¼¤µ¤âÀ©¸Â¤µ¤ì¤Ê¤¤¡£ Ï¢ÁÛÇÛÎó¤ÇÍѤ¤¤é¤ì¤ë¥Ï¥Ã¥·¥å¥Æ¡¼¥Ö¥ë¤âɬÍפ˱þ¤¸¤ÆÂ礭¤¯¤Ê¤ë¡£ ¤³¤ì¤Ï¥Ñ¥Õ¥©¡¼¥Þ¥ó¥¹¤òÍî¤È¤µ¤Ê¤¤¤¿¤á¤Ç¤¢¤ë¡£

perl ¤ÏÂçÎ̤Υǡ¼¥¿¤ò¿×®¤ËÁöºº¤¹¤ë¤¿¤á¤Ë ÀöÎý¤µ¤ì¤¿¥Ñ¥¿¡¼¥ó¥Þ¥Ã¥Á¤Î¥Æ¥¯¥Ë¥Ã¥¯¤ò»È¤Ã¤Æ¤¤¤ë¡£ ¥Æ¥­¥¹¥È¤òÁöºº¤¹¤ë¤Î¤ËºÇŬ²½¤µ¤ì¤Æ¤Ï¤¤¤ë¤¬¡¢perl ¤Ï¥Ð¥¤¥Ê¥ê¥Ç¡¼¥¿¤â°·¤¨¤ë¤·¡¢ (dbm ¤¬»È¤¨¤ë¤Ê¤é) dbm ¥Õ¥¡¥¤¥ë¤òÏ¢ÁÛÇÛÎ󤽤䯤ê¤Î·Á¤Ç°·¤¨¤ë¡£

¥Ç¡¼¥¿¥Õ¥í¡¼ÄÉÀ×µ¡¹½¤Î¤ª¤«¤²¤Ç Çϼ¯¤é¤·¤¤¥»¥­¥å¥ê¥Æ¥£¥Û¡¼¥ë¤òÈò¤±¤ë¤³¤È¤¬¤Ç¤­¤ë¤Î¤Ç¡¢ Setuid ¤µ¤ì¤¿ perl ¥¹¥¯¥ê¥×¥È¤Ï C ¥×¥í¥°¥é¥à¤è¤ê¤â°ÂÁ´¤Ç¤¢¤ë¡£

¤â¤·¡¢Ä̾ï¤Ê¤é sed ¤ä awk ¤ä sh ¤ò»È¤¦¤è¤¦¤ÊÌäÂê¤À¤¬ ¤·¤«¤·¤½¤ì¤é¤Ë¤Ï²Ù¤¬½Å¤¹¤®¤ë¾ì¹ç¡¢¤Þ¤¿¤Ï¤â¤¦¾¯¤·Á᤯Áö¤é¤»¤ëɬÍפ¬¤¢¤ë¤¬ ¤¯¤À¤é¤Ê¤¤¤³¤È¤ò C ¤Ç½ñ¤­¤¿¤¯¤Ï¤Ê¤¤¾ì¹ç¡¢perl ¤¬¤Ô¤Ã¤¿¤ê¤À¡£ sed ¤ä awk ¤Î¥¹¥¯¥ê¥×¥È¤«¤é perl ¥¹¥¯¥ê¥×¥È¤Ø¤ÎÊÑ´¹¥×¥í¥°¥é¥à¤â¤¢¤ë¡£

¤µ¤Æ¡¢ÀëÅÁ¤Ï¤³¤ì¤Ç½¼Ê¬¤À¡£

¥¹¥¯¥ê¥×¥È¤Î»ØÄêÊýË¡

µ¯Æ°»þ¡¢perl ¤Ï¼¡¤Î½ç½ø¤Ç¥¹¥¯¥ê¥×¥È¤òõ¤¹¡£

  1. ¥³¥Þ¥ó¥É¥é¥¤¥ó¤Î -e ¥¹¥¤¥Ã¥Á¤Ç 1 ¹Ô¤º¤Ä»ØÄꤹ¤ë¥¹¥¯¥ê¥×¥È¡£
  2. ¥³¥Þ¥ó¥É¥é¥¤¥ó¤ÎºÇ½é¤Î¥Õ¥¡¥¤¥ë̾¤Ç»ØÄꤵ¤ì¤ë¥Õ¥¡¥¤¥ë¤Ë´Þ¤Þ¤ì¤ë¥¹¥¯¥ê¥×¥È¡£ (#! »ØÄê¤ò¥µ¥Ý¡¼¥È¤¹¤ë¥·¥¹¥Æ¥à¤Ë¤ª¤¤¤Æ¤Ï¡¢ ¤³¤ÎÊýË¡¤Ç¥¤¥ó¥¿¥×¥ê¥¿¤¬µ¯Æ°¤µ¤ì¤ë)
  3. °ÅÌÛŪ¤Ëɸ½àÆþÎϤ«¤éÅϤµ¤ì¤ë¥¹¥¯¥ê¥×¥È¡£ ¤³¤ì¤Ï°ú¿ô¤Ë¥Õ¥¡¥¤¥ë̾¤¬°ì¤Ä¤â¤Ê¤¤¾ì¹ç¤À¤±¤Ç¤¢¤ë¡£ ɸ½àÆþÎϤΥ¹¥¯¥ê¥×¥È¤Ë°ú¿ô¤òÅϤ¹¤Ë¤Ï¡¢¥¹¥¯¥ê¥×¥È̾¤È¤·¤Æ ÌÀ¼¨Åª¤Ë `-' ¤ò»ØÄꤷ¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£

¥¹¥¯¥ê¥×¥È¤¬¸«¤Ä¤«¤ë¤È¡¢perl ¤Ï¤½¤ì¤òÆâÉô·Á¼°¤Ë¥³¥ó¥Ñ¥¤¥ë¤¹¤ë¡£ ¥¹¥¯¥ê¥×¥È¤¬Ê¸Ë¡Åª¤ËÀµ¤·¤±¤ì¤Ð¡¢¼Â¹Ô¤µ¤ì¤ë¡£

¥³¥Þ¥ó¥É¥é¥¤¥ó¥ª¥×¥·¥ç¥ó

1 ʸ»ú¥ª¥×¥·¥ç¥ó¤Ï¼¡¤Ë³¤¯¥ª¥×¥·¥ç¥ó¤¬¤¢¤ì¤Ð¡¢¤½¤ì¤È¤¯¤Ã¤Ä¤±¤Æ¤â¤è¤¤¡£ ÆÃ¤Ë #! µ¡¹½¤ò»È¤Ã¤Æµ¯Æ°¤¹¤ë»þ¤Ï°ú¿ô¤¬°ì¤Ä¤·¤«µö¤µ¤ì¤Ê¤¤¤Î¤Ç¡¢ ÊØÍø¤Ç¤¢¤ë¡£

#!/usr/bin/perl -spi.bak # -s -p -i.bak ¤ÈƱ¤¸
...

perl ¤Ë¤Ï°Ê²¼¤Î¥³¥Þ¥ó¥É¥é¥¤¥ó¥ª¥×¥·¥ç¥ó¤¬¤¢¤ë¡£

-0 : ¥ì¥³¡¼¥É¥»¥Ñ¥ì¡¼¥¿¤Î»ØÄê

`-0 ¿ô»ú'

¥ì¥³¡¼¥É¥»¥Ñ¥ì¡¼¥¿($/)¤ò8¿Ê¿ô¤Ç»ØÄꤹ¤ë¡£See section @hbox{@hbox to 1.6em{@tt@$/@hfil} : ÆþÎϥ쥳¡¼¥É¤Î¥»¥Ñ¥ì¡¼¥¿}.

¿ô»ú¤ò»ØÄꤷ¤Ê¤¤¾ì¹ç¤Ï¥Ì¥ë¥­¥ã¥é¥¯¥¿¤¬¥»¥Ñ¥ì¡¼¥¿¤Ë¤Ê¤ë¡£ ¿ô»ú¤ÎÁ°¤ä¸å¤Ë¾¤Î¥¹¥¤¥Ã¥Á¤¬¤¢¤Ã¤Æ¤â¤è¤¤¡£

Î㤨¤Ð¡¢ ¥Õ¥¡¥¤¥ë̾¤ÎºÇ¸å¤Ë¥Ì¥ë¥­¥ã¥é¥¯¥¿¤òÉÕ¤±¤Æ¥×¥ê¥ó¥È¤¹¤ë find ¤¬¤¢¤ë¤Ê¤é¡¢ ¼¡¤Î¤è¤¦¤Ë»È¤¨¤ë¡£

find . -name '*.bak' -print0 | perl -n0e unlink

00 ¤ÏÆüì¤ÊÃͤǡ¢perl ¤Ï¥Õ¥¡¥¤¥ë¤ò¥Ñ¥é¥°¥é¥Õ¥â¡¼¥É¤ÇÆɤ߹þ¤à¡£

0777 ¤ò»ØÄꤹ¤ë¤È¡¢ ¤½¤ÎÃͤò»ý¤Äʸ»ú¤Ï¤Ê¤¤¤Î¤Ç perl ¤ÏÁ´¥Õ¥¡¥¤¥ë¤òÆɤ߹þ¤à¡£

-a : ¥ª¡¼¥È¥¹¥×¥ê¥Ã¥È¥â¡¼¥É

`-a'

-n ¤ä -p ¤È°ì½ï¤ËÍѤ¤¤Æ¡¢ ¥ª¡¼¥È¥¹¥×¥ê¥Ã¥È¥â¡¼¥É¤ò ON ¤Ë¤¹¤ë¡£

-n ¤ä -p ¤Ë¤è¤ê¼«Æ°Åª¤Ë¹Ô¤ï¤ì¤ë while ¥ë¡¼¥×Æâ¤Ç¡¢ ºÇ½é¤Ë¼«Æ°Åª¤Ë split ¥³¥Þ¥ó¥É¤¬¼Â¹Ô¤µ¤ì¡¢ ¤½¤Î·ë²Ì¤¬ÇÛÎó @F ¤Ë¼ý¤á¤é¤ì¤ë¡£

perl -ane 'print pop(@F), "\n";'

¤Ï¼¡¤ÎÎã¤ÈƱÅù¤Ç¤¢¤ë¡£

while (<>) {
    @F = split(' ');
    print pop(@F), "\n";
}

-c : ʸˡ¥Á¥§¥Ã¥¯

`-c'

¥¹¥¯¥ê¥×¥È¤Îʸˡ¤ò¥Á¥§¥Ã¥¯¤·¡¢¼Â¹Ô¤»¤º¤Ë½ªÎ»¤¹¤ë¡£

-d : ¥Ç¥Ð¥Ã¥°¥â¡¼¥É

`-d'

perl ¥Ç¥Ð¥Ã¥¬¤Î¤â¤È¤Ç¥¹¥¯¥ê¥×¥È¤ò¼Â¹Ô¤¹¤ë¡£ ¥Ç¥Ð¥Ã¥¬¤Î¾Ï¤ò»²¾È¤Î¤³¤È¡£

See section perl ¥Ç¥Ð¥Ã¥¬.

-D : ¥Ç¥Ð¥Ã¥°¥Õ¥é¥°¤ò¥»¥Ã¥È¤¹¤ë

`-D¿ô»ú'

¥Ç¥Ð¥Ã¥°¥Õ¥é¥°¤ò¥»¥Ã¥È¤¹¤ë¡£

¥¹¥¯¥ê¥×¥È¤¬¤É¤Î¤è¤¦¤Ë¼Â¹Ô¤µ¤ì¤ë¤«¤ò¸«¤ë¤Ë¤Ï¡¢ `-D14' ¤ò»È¤¨¤Ð¤è¤¤ (¤³¤ì¤Ï¥Ç¥Ð¥Ã¥°¾ðÊó¤ò¤Ä¤±¤Æ perl ¤ò¥³¥ó¥Ñ¥¤¥ë¤·¤¿»þ¤Ë¤Î¤ßÆ°ºî¤¹¤ë)¡£

`-D1024' ¤âÍ­ÍѤÊÃͤǤ¢¤ë¡£ ¤³¤ì¤ò»È¤¦¤È¡¢¥³¥ó¥Ñ¥¤¥ë¤µ¤ì¤¿Ê¸Ë¡¥Ä¥ê¡¼¤ò¥ê¥¹¥È¤¹¤ë¡£

¤Þ¤¿¡¢`-D512' ¤ò»È¤¦¤È¡¢¥³¥ó¥Ñ¥¤¥ë¤µ¤ì¤¿Àµµ¬É½¸½¤ò½ÐÎϤ¹¤ë¡£

-e : ¥³¥Þ¥ó¥É¥é¥¤¥ó¤«¤é¥¹¥¯¥ê¥×¥È¤òÆþÎÏ

`-e ¥³¥Þ¥ó¥É¥é¥¤¥ó'

1 ¹Ô¤Î¥¹¥¯¥ê¥×¥È¤òÆþÎϤ¹¤ë¤Î¤ËÍѤ¤¤ë¡£ Ê£¿ô¹Ô¤Î¥¹¥¯¥ê¥×¥È¤ò»ØÄꤹ¤ë¤Ë¤Ï -e ¤òÊ£¿ô»ØÄꤹ¤ì¤Ð¤è¤¤¡£

-e ¤¬»ØÄꤵ¤ì¤ë¤È¡¢ perl ¤Ï°ú¿ô¤Î¥ê¥¹¥È¤«¤é¥¹¥¯¥ê¥×¥È¥Õ¥¡¥¤¥ë̾¤òõ¤µ¤Ê¤¤¡£

-i : ÆþÎÏ¥Õ¥¡¥¤¥ë¤ò½¤Àµ¤·¡¢¥Ð¥Ã¥¯¥¢¥Ã¥×¥Õ¥¡¥¤¥ë¤òºîÀ®¤¹¤ë

`-i³ÈÄ¥»Ò'

<> ¹½Â¤¤Ç½èÍý¤µ¤ì¤ë¥Õ¥¡¥¤¥ë¤ò¤½¤Î¾ì¤Ç½¤Àµ¤¹¤ë¤³¤È¤ò»ØÄꤹ¤ë¡£

ÆþÎÏ¥Õ¥¡¥¤¥ë¤Î̾Á°¤òÊѤ¨¤Æ¡¢½ÐÎÏ¥Õ¥¡¥¤¥ë¤ò¸µ¤Î̾Á°¤Ç¥ª¡¼¥×¥ó¤·¡¢ print ʸ¤Î¥Ç¥Õ¥©¥ë¥È¤Î½ÐÎÏ¥Õ¥¡¥¤¥ë¤È¤¹¤ë¤³¤È¤Ç½èÍý¤¹¤ë¡£

³ÈÄ¥»Ò¤¬Í¿¤¨¤é¤ì¤ì¤Ð¡¢¥Ð¥Ã¥¯¥¢¥Ã¥×¥Õ¥¡¥¤¥ë¤Î̾Á°¤È¤·¤Æ ¸µ¤Î¥Õ¥¡¥¤¥ë̾¤Ë¤½¤Î³ÈÄ¥»Ò¤ò²Ã¤¨¤¿¤â¤Î¤¬»È¤ï¤ì¤ë¡£

³ÈÄ¥»Ò¤¬¤Ê¤±¤ì¤Ð¡¢¥Ð¥Ã¥¯¥¢¥Ã¥×¤Ï¤µ¤ì¤Ê¤¤¡£

perl -p -i.bak -e "s/foo/bar/;" ... ¤ò¼Â¹Ô¤¹¤ë¤³¤È¤Ï ¼¡¤Î¥¹¥¯¥ê¥×¥È¤ÈƱ¤¸¤Ç¡¢

#!/usr/bin/perl -pi.bak
s/foo/bar/;

¤³¤ì¤Ï¼¡¤Î¤â¤Î¤ÈƱÅù¤Ç¤¢¤ë¡£

#!/usr/bin/perl
while (<>) {
     if ($ARGV ne $oldargv) {
        rename($ARGV, $ARGV . '.bak');
        open(ARGVOUT, ">$ARGV");
        select(ARGVOUT);
        $oldargv = $ARGV;
     }
     s/foo/bar/;
}
continue {
    print;     # ¸µ¤Î̾Á°¤Î¥Õ¥¡¥¤¥ë¤Ë½ÐÎϤ¹¤ë
}
select(STDOUT);

¤¿¤À¤·¡¢-i ¤òÍѤ¤¤¿ÊýË¡¤Ç¤Ï ¥Õ¥¡¥¤¥ë̾¤¬¤¤¤ÄÊѹ¹¤µ¤ì¤¿¤«¤òÄ´¤Ù¤ë¤¿¤á¤Ë $ARGV ¤È $oldargv ¤ò Èæ³Ó¤¹¤ëɬÍפ¬¤Ê¤¤ÅÀ¤¬°Û¤Ê¤ë¡£-i ¤òÍѤ¤¤¿¾ì¹ç¡¢ ¼ÂºÝ¤Ë¥»¥ì¥¯¥È¤¹¤ë¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤È¤·¤Æ ARGVOUT ¤ò»È¤Ã¤Æ¤¤¤ë¡£

¥ë¡¼¥×¤Î¸å¤Ç ¥Ç¥Õ¥©¥ë¥È¤Î½ÐÎÏ¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤¬ STDOUT ¤ËÌᤵ¤ì¤Æ¤¤¤ëÅÀ¤ËÃí°Õ¡£

ÆþÎÏ¥Õ¥¡¥¤¥ë¤¹¤Ù¤Æ¤ËÄɲäò¹Ô¤Ã¤¿¤ê¡¢¹ÔÈÖ¹æ¤ò¥ê¥»¥Ã¥È¤·¤¿¤ê¤¹¤ë¾ì¹ç¡¢ ³Æ¡¹¤ÎÆþÎÏ¥Õ¥¡¥¤¥ë¤Î½ª¤ï¤ê¤òÃΤ뤿¤á¤Ë eof ¤ò»È¤¦¤³¤È¤¬¤Ç¤­¤ë¡£ (eof ¤Ç¤ÎÎã¤ò»²¾È¡£See section eof.)

-I : C ¥×¥ê¥×¥í¥»¥Ã¥µ¤Ë¥¤¥ó¥¯¥ë¡¼¥É¥Õ¥¡¥¤¥ë¤Î°ÌÃÖ¤òÃΤ餻¤ë

`-I¥Ç¥£¥ì¥¯¥È¥ê'

-P ¤È°ì½ï¤ËÍѤ¤¤Æ C ¥×¥ê¥×¥í¥»¥Ã¥µ¤Ë ¥¤¥ó¥¯¥ë¡¼¥É¥Õ¥¡¥¤¥ë¤Î°ÌÃÖ¤òÃΤ餻¤ë¡£

¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï `/usr/include' ¤È `/usr/lib/perl' ¤ò¸¡º÷¤¹¤ë¡£

-l : ¹ÔËö½èÍý¤ò¼«Æ°Åª¤Ë¹Ô¤¦

`-l 8¿Ê¿ô'

¹ÔËö½èÍý¤ò¼«Æ°Åª¤Ë¹Ô¤¦¡£Æó¤Ä¤Î¸ú²Ì¤¬¤¢¤ë:

  1. -n ¤Þ¤¿¤Ï -p ¤È°ì½ï¤ËÍѤ¤¤¿¾ì¹ç¡¢ ¹Ô¥¿¡¼¥ß¥Í¡¼¥¿¤ò¼«Æ°Åª¤Ë½ü¤¯¡£
  2. $\ ¤Ë 8 ¿Ê¤ÎÃͤò¥»¥Ã¥È¤·¡¢ print ʸ¤¬Á´¤ÆºÇ¸å¤Ë¹Ô¥¿¡¼¥ß¥Í¡¼¥¿¤ò¤Ä¤±¤ë¤è¤¦¤Ë¤¹¤ë¡£ 8 ¿Ê¿ô¤ò¾Êά¤¹¤ë¤È¡¢$/ ¤ÎÃͤò $\ ¤Ë¥»¥Ã¥È¤¹¤ë¡£

Î㤨¤Ð¡¢¹Ô¤ò 80 ¥³¥é¥à¤ËÀڤ귤¨¤ë¤¿¤á¤Ë¤Ï:

perl -lpe 'substr($_, 80) = ""'

Ãí°Õ:
$\ = $/ ¤ÎÂåÆþ¤Ï¥¹¥¤¥Ã¥Á¤¬½èÍý¤µ¤ì¤ë»þ¤Ë¹Ô¤Ê¤ï¤ì¤ë¤Î¤Ç¡¢ -l ¤Î¸å¤Ë -0 ¤¬¤¢¤ë¾ì¹ç¡¢ ÆþÎϥ쥳¡¼¥É¥»¥Ñ¥ì¡¼¥¿¤¬½ÐÎϥ쥳¡¼¥É¥»¥Ñ¥ì¡¼¥¿¤È°ã¤¦Ãͤò»ý¤Ä¾ì¹ç¤¬¤¢¤ë:

gnufind / -print0 | perl -ln0e 'print "found $_" if -p'

¤³¤Î¾ì¹ç¤Ï $\ ¤ò²þ¹Ô¡¢$/ ¤ò¥Ì¥ë¥­¥ã¥é¥¯¥¿¤Ë¥»¥Ã¥È¤¹¤ë¡£

See section @hbox{@hbox to 1.6em{@tt@$@char'134@hfil} : print ´Ø¿ô¤ÎºÇ¸å¤Ë½ÐÎϤ¹¤ë¥»¥Ñ¥ì¡¼¥¿}, ¤ª¤è¤Ó See section @hbox{@hbox to 1.6em{@tt@$/@hfil} : ÆþÎϥ쥳¡¼¥É¤Î¥»¥Ñ¥ì¡¼¥¿}.

-n : sed -n ¤ä awk ¤Î¥¨¥ß¥å¥ì¡¼¥È

`-n'

¥¹¥¯¥ê¥×¥È¤ÎÁ°¸å¤Ë²¼¤Ë¼¨¤¹¥ë¡¼¥×¤¬¤¢¤ë¤â¤Î¤È¤·¤Æ perl ¤òµ¯Æ°¤¹¤ë¡£ ¤³¤¦¤¹¤ë¤È¡¢°ú¿ô¤Î¥Õ¥¡¥¤¥ëÁ´Éô¤Ë¤Ä¤¤¤Æ·«¤êÊÖ¤·¤¬¹Ô¤ï¤ì¤ë (sed -n ¤ä awk ¤Î¤è¤¦¤Ë)¡£

while (<>) {
     ... # ¥¹¥¯¥ê¥×¥È¤¬¤³¤³¤Ë¤¯¤ë
}

¥Ç¥Õ¥©¥ë¥È¤Ç¤ÏÆþÎϹԤνÐÎϤ¬¤Ê¤µ¤ì¤Ê¤¤¤³¤È¤ËÃí°Õ¡£ ½ÐÎϤ·¤¿¤±¤ì¤Ð¡¢-p ¤òÍѤ¤¤ë¡£

°Ê²¼¤Ë¼¨¤¹Îã¤Ï°ì½µ´Ö°Ê¾åÁ°¤Î¥Õ¥¡¥¤¥ë¤ò¸úΨŪ¤ËÁ´¤Æ¾Ãµî¤¹¤ëÊýË¡¤Ç¤¢¤ë¡£

find . -mtime +7 -print | perl -nle 'unlink;'

¤³¤¦¤¹¤ë¤È find ¤Î -exec ¥¹¥¤¥Ã¥Á¤ò»È¤¦¤è¤ê¤â®¤¤¡£ ¤Ê¤¼¤Ê¤é¡¢¥Õ¥¡¥¤¥ë̾¤¬¸«¤Ä¤«¤ë¤¿¤Ó¤Ë¥×¥í¥»¥¹¤òµ¯Æ°¤¹¤ëɬÍפ¬¤Ê¤¤¤«¤é¤Ç¤¢¤ë¡£

-p : sed ¤Î¥¨¥ß¥å¥ì¡¼¥È

`-p'

¥¹¥¯¥ê¥×¥È¤ÎÁ°¸å¤Ë²¼¤Ë¼¨¤¹¥ë¡¼¥×¤¬¤¢¤ë¤â¤Î¤È¤·¤Æ perl ¤òµ¯Æ°¤¹¤ë¡£ ¤³¤¦¤¹¤ë¤È¡¢°ú¿ô¤Î¥Õ¥¡¥¤¥ëÁ´Éô¤Ë¤Ä¤¤¤Æ·«¤êÊÖ¤·¤¬¹Ô¤ï¤ì¤ë(sed ¤Î¤è¤¦¤Ë)¡£

while (<>) {
     ... # ¥¹¥¯¥ê¥×¥È¤¬¤³¤³¤Ë¤¯¤ë
} continue {
     print;
}

ÆþÎϹԤ¬¼«Æ°Åª¤Ë½ÐÎϤµ¤ì¤ë¤³¤È¤ËÃí°Õ¡£ ½ÐÎϤ·¤Ê¤¤¤è¤¦¤Ë¤¹¤ë¤Ë¤Ï -n ¤òÍѤ¤¤ë¡£ -p ¤Ï -n ¤ËÍ¥À褹¤ë¡£

-P : ¥³¥ó¥Ñ¥¤¥ëÁ°¤Ë C ¥×¥ê¥×¥í¥»¥Ã¥µ¤òÄ̤¹

`-P'

perl ¤Î¥³¥ó¥Ñ¥¤¥ë¤ÎÁ°¤Ë C ¥×¥ê¥×¥í¥»¥Ã¥µ¤òÄ̤¹¡£ (perl ¤Î¥³¥á¥ó¥È¤â cpp ¤ÎÌ¿Îá¤â # ¤Ç»Ï¤Þ¤ë¤Î¤Ç¡¢ ¥³¥á¥ó¥È¤ò C ¥×¥ê¥×¥í¥»¥Ã¥µ¤¬Íý²ò¤¹¤ëñ¸ì¡¢ Î㤨¤Ð `if' ¤ä `else' ¤ä `define' ¤Ç »Ï¤á¤Ê¤¤¤è¤¦¤Ë¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£)

-s : ¥³¥Þ¥ó¥É¥é¥¤¥ó¥ª¥×¥·¥ç¥ó¤Î²òÀÏ·ë²Ì¤òÊÑ¿ô¤Ë¥»¥Ã¥È¤¹¤ë

`-s'

¥³¥Þ¥ó¥É¥é¥¤¥ó¤Î¥¹¥¯¥ê¥×¥È̾¤Î¸å¡¢ ¥Õ¥¡¥¤¥ë̾¤Î°ú¿ô(¤Þ¤¿¤Ï `--')¤ÎÁ°¤Î¥¹¥¤¥Ã¥Á¤Ë¤Ä¤¤¤Æ½éÊâŪ¤Ê²òÀϤò¹Ô¤¦¡£

¥¹¥¤¥Ã¥Á¤¬¸«¤Ä¤«¤ë¤È¡¢@ARGV ¤«¤é½ü¤«¤ì¡¢ Âбþ¤¹¤ëÊÑ¿ô¤ò perl ¥¹¥¯¥ê¥×¥ÈÆâ¤Ç¥»¥Ã¥È¤¹¤ë¡£ ¼¡¤Î¥¹¥¯¥ê¥×¥È¤Ç¤Ï¡¢`-xyz' ¥¹¥¤¥Ã¥Á¤ò¤Ä¤±¤Æ¥¹¥¯¥ê¥×¥È¤òµ¯Æ°¤·¤¿»þ¡¢ ¤Þ¤¿¤½¤Î»þ¤Î¤ß `true' ¤ò½ÐÎϤ¹¤ë¡£

#!/usr/bin/perl -s
if ($xyz) { print "true\n"; }

-S : ¥¹¥¯¥ê¥×¥È¤ò´Ä¶­ÊÑ¿ô PATH ¤òÍѤ¤¤Æõ¤¹

`-S'

¥¹¥¯¥ê¥×¥È¤òõ¤¹¤Î¤Ë¡¢´Ä¶­ÊÑ¿ô PATH ¤òÍѤ¤¤ë (¥¹¥¯¥ê¥×¥È̾¤¬ `/' ¤Ç»Ï¤Þ¤é¤Ê¤¤¤«¤®¤ê)¡£ ¤³¤ì¤ÏÆÃ¤Ë #! ¤ò¥µ¥Ý¡¼¥È¤·¤Ê¤¤¥Þ¥·¥ó¤Ë¤ª¤¤¤Æ #! ¤ò ¥¨¥ß¥å¥ì¡¼¥È¤¹¤ë¤Î¤ËÍѤ¤¤é¤ì¤ë¡£¤½¤Î»È¤¤Êý¤Ï°Ê²¼¤ÎÄ̤ê¤Ç¤¢¤ë¡£

#!/usr/bin/perl
eval "exec /usr/bin/perl -S $0 $*"
     if $running_under_some_shell;

¥·¥¹¥Æ¥à¤Ï 1 ¹ÔÌܤò̵»ë¤·¡¢¥¹¥¯¥ê¥×¥È¤ò `/bin/sh' ¤ËÅϤ¹¡£ `/bin/sh' ¤Ï perl ¥¹¥¯¥ê¥×¥È¤ò¥·¥§¥ë¥¹¥¯¥ê¥×¥È¤È¤·¤Æ¼Â¹Ô¤·¤è¤¦¤È¤¹¤ë¡£ ¥·¥§¥ë¤Ï 2 ¹ÔÌܤòÄ̾ï¤Î¥·¥§¥ë¥³¥Þ¥ó¥É¤È¤·¤Æ¼Â¹Ô¤·¡¢ perl ¥¤¥ó¥¿¥×¥ê¥¿¤òµ¯Æ°¤¹¤ë¡£

¥·¥¹¥Æ¥à¤Ë¤è¤Ã¤Æ¤Ï $0 ¤Ïɬ¤º¤·¤â¥Õ¥ë¥Ñ¥¹¤ò´Þ¤Þ¤Ê¤¤¤Î¤Ç¡¢ -S ¤òÍѤ¤¤Æ perl ¤ËɬÍפʤé¤Ð¥¹¥¯¥ê¥×¥È¤òõ¤¹¤è¤¦¤Ë»Ø¼¨¤¹¤ë¡£ perl ¤¬¥¹¥¯¥ê¥×¥È¤ò¸«¤Ä¤±¤ë¤È¡¢²òÀϤò¹Ô¤¤¡¢ ÊÑ¿ô $running_under_some_shell ¤¬¿¿¤Ë¤Ê¤ë¤³¤È¤Ï¤Ê¤¤¤Î¤Ç¡¢ 2 ¹ÔÌܤò̵»ë¤¹¤ë¡£

¥Õ¥¡¥¤¥ë̾¤Ë´Þ¤Þ¤ì¤ë¥¹¥Ú¡¼¥¹¤Ê¤É¤òÀµ¤·¤¯°·¤¦¤Ë¤Ï¡¢ $* ¤è¤ê¤â ${1+"$@"} ¤Î¤Û¤¦¤¬¤è¤¤¤À¤í¤¦¤¬¡¢ csh ¤¬²ò¼á¤¹¤ë¾ì¹ç¤Ë¤ÏÆ°ºî¤·¤Ê¤¤¡£

sh ¤Ç¤Ï¤Ê¤¯¤Æ csh ¤Çµ¯Æ°¤¹¤ë¤Ë¤Ï¡¢¤¢¤ë¥·¥¹¥Æ¥à¤Ç¤Ï #! ¹Ô¤ò ¥³¥í¥ó¤Î¤ß¤ò´Þ¤à¹Ô¤Ë½ñ¤­´¹¤¨¤ëɬÍפ¬¤¢¤ë¤«¤â¤·¤ì¤Ê¤¤¡£ perl ¤Ï¤³¤Î¹Ô¤ò̵»ë¤¹¤ë¡£¤½¤Î¾¤Î¥·¥¹¥Æ¥à¤Ç¤Ï¤³¤ÎÊýË¡¤Ï»È¤¨¤º¡¢ ¼¡¤Î¤è¤¦¤Ë¡¢csh¡¢sh¡¢perl ¤Î¤É¤ì¤Ç¤âÆ°ºî¤¹¤ë¤è¤¦¤Ê¡¢ ¤È¤Æ¤â¤ä¤ä¤³¤·¤¤ÊýË¡¤ò¤È¤ëɬÍפ¬¤¢¤ë¡£

eval '(exit $?0)' && eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
& eval 'exec /usr/bin/perl -S $0 $argv:q'
        if 0;

-u : ¥¹¥¯¥ê¥×¥È¤Î¥³¥ó¥Ñ¥¤¥ë¸å¡¢¥³¥¢¥À¥ó¥×¤¹¤ë

`-u'

¥¹¥¯¥ê¥×¥È¤Î¥³¥ó¥Ñ¥¤¥ë¤Î¸å¡¢¥³¥¢¥À¥ó¥×¤¹¤ë¡£

¤³¤Î¥³¥¢¥À¥ó¥×¤«¤é¡¢undump ¥×¥í¥°¥é¥à(Ä󶡤·¤Æ¤¤¤Ê¤¤)¤òÍѤ¤¤Æ ¼Â¹Ô²Äǽ¥Õ¥¡¥¤¥ë¤ËÊÑ´¹¤Ç¤­¤ë¡£¤³¤¦¤¹¤ë¤È¡¢ ¥Ç¥£¥¹¥¯¾ÃÈñ¤¬Áý¤¨¤ë¤«¤ï¤ê¤Ë(¼Â¹Ô¥Õ¥¡¥¤¥ë¤ò strip ¤¹¤ì¤ÐºÇ¾®¤Ë¤Ç¤­¤ë) ¥¹¥¿¡¼¥È¥¢¥Ã¥×¤¬Â®¤¯¤Ê¤ë¡£(¤·¤«¤·¡¢ »ä¤Î¥Þ¥·¥ó¤Ç¤Ï "hello world" ¤Î¼Â¹Ô·Á¼°¤¬ 200k ¤ÎÂ礭¤µ¤Ë¤Ê¤ë¡£)

¤³¤Î¼Â¹Ô·Á¼°¤ò set-id ¥×¥í¥°¥é¥à¤È¤·¤ÆÁö¤é¤»¤ë¤Î¤Ê¤é¡¢ Ä̾ï¤Î perl ¤Ç¤Ï¤Ê¤¯ `taintperl' ¤òÍѤ¤¤Æ¥³¥ó¥Ñ¥¤¥ë¤·¤¿Êý¤¬Îɤ¤¡£

¥À¥ó¥×¤¹¤ëÁ°¤Ë¼Â¹Ô¤·¤¿¤¤¥¹¥¯¥ê¥×¥È¤¬¤¢¤ë¾ì¹ç¤Ï¡¢ Âå¤ï¤ê¤Ë dump ¥³¥Þ¥ó¥É¤ò»È¤¨¤Ð¤è¤¤¡£

Ãí°Õ : undump ¤¬»È¤¨¤ë¤«¤É¤¦¤«¤Ï¥×¥é¥Ã¥È¥Õ¥©¡¼¥à¤Ë¤è¤ë¤Î¤Ç¡¢ ¥Þ¥·¥ó¤Ë¤è¤Ã¤Æ¤ÏÍøÍѤǤ­¤Ê¤¤¤â¤Î¤â¤¢¤ë¡£See section dump.

-U : °ÂÁ´¤Ç¤Ê¤¤Áàºî¤ò²Äǽ¤Ë¤¹¤ë

`-U'

°ÂÁ´¤Ç¤Ê¤¤Áàºî¤ò²Äǽ¤Ë¤¹¤ë¡£

¸½ºß¤Î½ê¡¢"°ÂÁ´¤Ç¤Ê¤¤"Áàºî¤È¤Ï¡¢¥¹¡¼¥Ñ¡¼¥æ¡¼¥¶¤Î¸¢¸Â¤ÇÁö¤é¤»¤Æ¤¤¤ëºÝ ¤Ë¥Ç¥£¥ì¥¯¥È¥ê¤ò unlink ¤¹¤ë¤³¤È¡¢¤ª¤è¤Ó"±ø¤ì"¥Á¥§¥Ã¥¯¤Î·ë²Ì¡¢ ·Ù¹ð¤¬½Ð¤ë¤è¤¦¤Ê setuid ¥×¥í¥°¥é¥à¤òÁö¤é¤»¤ë¤³¤È¤À¤±¤Ç¤¢¤ë¡£

See section Setuid ¥¹¥¯¥ê¥×¥È.

-v : perl ¤Î¥Ð¡¼¥¸¥ç¥ó¤È¥Ñ¥Ã¥Á¥ì¥Ù¥ë¤òɽ¼¨¤¹¤ë

`-v'

perl ¤Î¥Ð¡¼¥¸¥ç¥ó¤È¥Ñ¥Ã¥Á¥ì¥Ù¥ë¤ò½ÐÎϤ¹¤ë¡£

-w : ¼±Ê̻Ҥ˴ؤ¹¤ë¤µ¤Þ¤¶¤Þ¤Ê·Ù¹ð¤ò½Ð¤¹

`-w'

¼±Ê̻ҤˤĤ¤¤Æ°Ê²¼¤Î¾ì¹ç¤Ë·Ù¹ð¤ò½Ð¤¹¡£

-x : ¥¹¥¯¥ê¥×¥È¤¬¥á¥Ã¥»¡¼¥¸Æâ¤ËËä¤á¹þ¤Þ¤ì¤Æ¤¤¤ë¤³¤È¤òÃΤ餻¤ë

`-x¥Ç¥£¥ì¥¯¥È¥ê'

¥¹¥¯¥ê¥×¥È¤¬¥á¥Ã¥»¡¼¥¸Æâ¤ËËä¤á¹þ¤Þ¤ì¤Æ¤¤¤ë¤³¤È¤ò perl ¤ËÃΤ餻¤ë¡£ #! ¤Ç»Ï¤Þ¤ê¡¢ `perl' ¤È¤¤¤¦Ê¸»úÎó¤ò´Þ¤àºÇ½é¤Î¹Ô¤¬¸½¤ì¤ë¤Þ¤Ç¤Î¥´¥ß¤Ï̵»ë¤µ¤ì¤ë¡£ ¤½¤Î¹Ô¤Ë»ØÄꤷ¤¿°ÕÌ£¤Î¤¢¤ë¥¹¥¤¥Ã¥Á¤Ï¤¹¤Ù¤ÆŬÍѤµ¤ì¤ë (¤¿¤À¤·Ä̾ï¤Î #! ½èÍý¤ÈƱ¤¸¤¯¡¢¥¹¥¤¥Ã¥Á¤Î¤«¤¿¤Þ¤ê¤Ò¤È¤Ä¤À¤±¤Ç¤¢¤ë)¡£

¥Ç¥£¥ì¥¯¥È¥ê̾¤ò»ØÄꤹ¤ë¤È¡¢ perl ¤Ï¥¹¥¯¥ê¥×¥È¤ò¼Â¹Ô¤¹¤ëÁ°¤Ë¤½¤Î¥Ç¥£¥ì¥¯¥È¥ê¤Ë°Ü¤ë¡£

-x ¤ÏÀèƬ¤Î¥´¥ß¤Î¤ß¤ò¼Î¤Æ¤ë¡£ ¥¹¥¯¥ê¥×¥È¤Î¸å¤Ë¥´¥ß¤¬¤¢¤ë¾ì¹ç¤Ï¡¢ ¥¹¥¯¥ê¥×¥È¤ò __END__ ¤Ç½ª¤ï¤é¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤ (˾¤à¤Ê¤é¡¢¥¹¥¯¥ê¥×¥È¤Ç¸å¤í¤Î¥´¥ß¤Î°ìÉô¤Þ¤¿¤ÏÁ´Éô¤ò ¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë DATA ·Ðͳ¤Ç½èÍý¤¹¤ë¤³¤È¤Ï²Äǽ¤Ç¤¢¤ë)¡£

__END__ ¤Ë¤Ä¤¤¤Æ¤Ï See section ʸ»úÎó¤Î°·¤¤.

¥Ç¡¼¥¿¤Î·¿¤È¥ª¥Ö¥¸¥§¥¯¥È

¥Ç¡¼¥¿¤Î·¿¡¦¥³¥ó¥Æ¥­¥¹¥È

perl ¤Ë¤Ï 3 ¼ïÎà¤Î¥Ç¡¼¥¿·¿ : ¥¹¥«¥é¡¼¡¢¥¹¥«¥é¡¼ÇÛÎ󡢤ª¤è¤ÓÏ¢ÁÛÇÛÎ󤬤¢¤ë¡£ Ä̾ï¤ÎÇÛÎó¤Ïź¤¨»ú¤¬¿ô»ú¤À¤¬¡¢Ï¢ÁÛÇÛÎó¤Î¾ì¹ç¤Ïʸ»úÎó¤Ç¤¢¤ë¡£

perl ¤Ë¤ª¤±¤ë±é»»¤äÃͤβò¼á¤Ï¡¢ ±é»»¤äÃͤΥ³¥ó¥Æ¥­¥¹¥È¤«¤é¤ÎÍ×µá¤Ë°Í¸¤¹¤ë¤³¤È¤¬¤¢¤ë¡£ ¼ç¤Ê¥³¥ó¥Æ¥­¥¹¥È¤Ë¤Ï 3 ¤Ä : ʸ»úÎ󡢿ôÃÍ¡¢¤ª¤è¤ÓÇÛÎ󤬤¢¤ë¡£ ±é»»¤ÎÃæ¤Ë¤Ï¡¢ÇÛÎó¤òÍ׵᤹¤ë¥³¥ó¥Æ¥­¥¹¥È¤Ç¤ÏÇÛÎó¤ò¡¢ ¤½¤¦¤Ç¤Ê¤±¤ì¤Ð¥¹¥«¥é¡¼ÃͤòÊÖ¤¹¤â¤Î¤¬¤¢¤ë¡£ (¤½¤Î¤è¤¦¤Ê±é»»»Ò¤Ë¤Ä¤¤¤Æ¤Ï¤½¤Î¥É¥­¥å¥á¥ó¥È¤Ëµ­½Ò¤µ¤ì¤Æ¤¤¤ë¡£) ¥¹¥«¥é¡¼ÃͤòÊÖ¤¹±é»»»Ò¤Ï¡¢ ¥³¥ó¥Æ¥­¥¹¥È¤¬Ê¸»úÎ󤢤뤤¤Ï¿ôÃͤΤɤÁ¤é¤òÍ׵ᤷ¤Æ¤¤¤ë¤«¤Ï¹Íθ¤·¤Ê¤¤¤¬¡¢ ¥¹¥«¥é¡¼ÊÑ¿ô¤ª¤è¤Ó¥¹¥«¥é¡¼ÃÍ¤Ï Ê¸»úÎ󤢤뤤¤Ï¿ôÃͤΥ³¥ó¥Æ¥­¥¹¥È¤Î¤Õ¤µ¤ï¤·¤¤Êý¤Ë²ò¼á¤µ¤ì¤ë¡£ ¥¹¥«¥é¡¼¤Ï¤½¤ì¤¬¥Ì¥ëʸ»úÎ󤢤뤤¤Ï 0 ¤Ç¤Ê¤±¤ì¤ÐÏÀÍýŪ¤Ë¿¿¤Ç¤¢¤ë¤È²ò¼á¤µ¤ì¤ë¡£ ±é»»»Ò¤¬ÊÖ¤¹ÏÀÍýÃͤϿ¿¤Î¾ì¹ç¤Ï 1¡¢ µ¶¤Î¾ì¹ç¤Ï 0 ¤Þ¤¿¤Ï " (¥Ì¥ëʸ»úÎó)¤Ç¤¢¤ë¡£

¼Â¤Ï¡¢¥Ì¥ëʸ»úÎó¤Ë¤Ï 2 ¼ïÎढ¤ë¡£ define ¤µ¤ì¤¿¤â¤Î¡¢undefined ¤Î¤â¤Î¤Ç¤¢¤ë¡£ undefined ¤Î¥Ì¥ëʸ»úÎó¤Ï¥¨¥é¡¼¤ä¡¢end of file ¤ä¡¢ ½é´ü²½¤µ¤ì¤Æ¤¤¤Ê¤¤ÊÑ¿ô¤äÇÛÎóÍ×ÁǤò»²¾È¤·¤è¤¦¤È¤·¤¿»þ¤Ê¤É¡¢ ¼ÂºÝ¤ÎÃͤ¬Â¸ºß¤·¤Ê¤¤»þ¤ËÊ֤롣 undefined ¥Ì¥ëʸ»úÎó¤ÏºÇ½é¤Ë¤½¤ì¤Ë¥¢¥¯¥»¥¹¤¹¤ë¤³¤È¤Ë¤è¤ê¡¢ defined ¤Ë¤Ê¤ë¤³¤È¤¬¤¢¤ë¤¬¡¢¤½¤ÎÁ°¤Ë defined() ±é»»»Ò¤òÍѤ¤¤Æ Ãͤ¬ defined ¤«¤½¤¦¤Ç¤Ê¤¤¤«¤òÃΤ뤳¤È¤¬¤Ç¤­¤ë¡£

¥¹¥«¥é¡¼ÊÑ¿ô¤Ø¤Î»²¾È¤Ï¡¢¤½¤ì¤¬ÇÛÎó¤Î°ìÉô¤Ç¤¢¤Ã¤Æ¤â¡¢ ¾ï¤Ë `$' ¤Ç»Ï¤á¤ë¡£¤¹¤Ê¤ï¤Á¡¢°Ê²¼¤ÎÄ̤ê¤Ç¤¢¤ë¡£

$days            # ñ½ã¤Ê¥¹¥«¥é¡¼ÊÑ¿ô
$days[28]        # ÇÛÎó @days ¤Î 29 ÈÖÌܤÎÍ×ÁÇ
$days{'Feb'}     # Ï¢ÁÛÇÛÎó¤ÎÃͤΰì¤Ä
$#days           # ÇÛÎó @days ¤ÎºÇ¸å¤Îź¤¨»ú

¤·¤«¤·¡¢ÇÛÎóÁ´Éô¤ä°ìÉô¤Î¼è¤ê½Ð¤·¤Ê¤É¤Ï '@' ¤Ç»Ï¤á¤ë¡£

@days	        # ($days[0], $days[1],... $days[n])
@days[3,4,5]  # @days[3..5] ¤ÈƱ¤¸
@days{a,c}    # ($days{'a'},$days{'c'}) ¤ÈƱ¤¸

¤½¤·¤ÆÏ¢ÁÛÇÛÎóÁ´Éô¤ò°·¤¦¤Ë¤Ï¡¢'%' ¤Ç»Ï¤á¤ë¡£

%days		# (key1, val1, key2, val2 ...)

¤³¤ì¤é 8 ¤Ä¤Ï¤¹¤Ù¤Æº¸ÊÕÃͤȤ·¤Æ°·¤¦¤³¤È¤¬¤Ç¤­¤ë¡£¤¹¤Ê¤ï¤Á¡¢ÂåÆþ²Äǽ¤Ç¤¢¤ë¡£ (¤µ¤é¤Ë¡¢¤¢¤ë¥³¥ó¥Æ¥­¥¹¥È¤Ç¤ÏÂåÆþÁàºî¼«ÂΤ⺸ÊÕÃͤȤʤꤦ¤ë¡£ s¡¢tr ¤ª¤è¤Ó chop ¤Ë¤ª¤±¤ëÎã¤ò»²¾È¤Î¤³¤È¡£) See section s/¥Ñ¥¿¡¼¥ó/ÃÖ¤­´¹¤¨/, See section tr/¸¡º÷¥ê¥¹¥È/ÃÖ´¹¥ê¥¹¥È/, ¤ª¤è¤Ó See section chop.

¥¹¥«¥é¡¼¤Ø¤ÎÂåÆþ¤ò¹Ô¤¦¤È¡¢±¦ÊÕ¤ò¥¹¥«¥é¡¼¤Î¥³¥ó¥Æ¥­¥¹¥È¤Çɾ²Á¤¹¤ë¤Î¤ËÂФ·¡¢ ÇÛÎó¤äÇÛÎó¤Î°ìÉô¤Ø¤ÎÂåÆþ¤Ï±¦ÊÕ¤òÇÛÎó¤Î¥³¥ó¥Æ¥­¥¹¥È¤Çɾ²Á¤¹¤ë¡£

ÇÛÎó @days ¤ÎŤµ¤ò¡¢csh ¤Î¤è¤¦¤Ë¡¢ `$#days' ¤Çɾ²Á¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë(¼ÂºÝ¤Ë¤Ï¡¢ÇÛÎó¤ÎŤµ¤Ç¤Ï¤Ê¤¯¡¢ ºÇ¸å¤ÎÍ×ÁǤÎź¤¨»ú¤Ç¤¢¤ë¡£¤Ê¤¼¤Ê¤é¡¢Ä̾ï 0 ÈÖÌܤÎÍ×ÁǤ¬¤¢¤ë¤«¤é¤Ç¤¢¤ë)¡£

$#days ¤ØÂåÆþ¤¹¤ë¤È¡¢ÇÛÎó¤ÎŤµ¤¬ÊѤï¤ë¡£ ¤³¤ÎÊýË¡¤Ë¤è¤êÇÛÎó¤ò¾®¤µ¤¯¤·¤Æ¤â¡¢¼ÂºÝ¤Ë¤ÏÃͤϲ¿¤âÇ˲õ¤µ¤ì¤Ê¤¤¡£ ¤¹¤Ç¤Ë¾®¤µ¤¯¤·¤¿ÇÛÎó¤òÂ礭¤¯¤¹¤ë¤È¡¢¤â¤È¤â¤È¤¢¤Ã¤¿Í×ÁǤ¬¸µ¤ËÌá¤ë¡£

¤Þ¤¿¡¢Â礭¤¯¤Ê¤ê¤½¤¦¤ÊÇÛÎó¤ò¤¢¤é¤«¤¸¤áÂ礭¤¯¤·¤Æ¤ª¤¯¤È¡¢ ¸úΨ¤ò¤¤¤¯¤é¤«Îɤ¯¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£(ÇÛÎó¤òÂ礭¤¯¤¹¤ë¤Ë¤Ï¡¢ ÇÛÎó¤ÎºÇ¸å¤òĶ¤¨¤ëÍ×ÁǤËÂåÆþ¤ò¹Ô¤¦ÊýË¡¤â¤¢¤ë¡£¤³¤ÎÊýË¡¤È¡¢ $#whatever ¤ØÂåÆþ¤¹¤ëÊýË¡¤È¤Î°ã¤¤¤Ï¡¢ ´Ö¤ÎÍ×ÁǤ˥̥뤬¥»¥Ã¥È¤µ¤ì¤ë¤³¤È¤Ç¤¢¤ë¡£)

ÇÛÎó¤ÎÃæ¿È¤ò¼Î¤Æ¤Æ¶õ¤Ë¤¹¤ë¤Ë¤Ï¡¢¥Ì¥ë¥ê¥¹¥È () ¤òÂåÆþ¤¹¤ì¤ÐÎɤ¤¡£ ¼¡¤ÎÆó¤Ä¤ÏÁ´¤¯Æ±Åù¤Ç¤¢¤ë¡£

@whatever = ();
$#whatever = $[ - 1;

ÇÛÎó¤ò¥¹¥«¥é¡¼¤Î¥³¥ó¥Æ¥­¥¹¥È¤Çɾ²Á¤¹¤ë¤È¡¢ÇÛÎó¤ÎŤµ¤¬Ê֤롣 ¼¡¤Î¼°¤Ï¾ï¤Ë¿¿¤Ç¤¢¤ë¡£

scalar(@whatever) == $#whatever - $[ + 1;

Ï¢ÁÛÇÛÎó¤ò¥¹¥«¥é¡¼¤Î¥³¥ó¥Æ¥­¥¹¥È¤Çɾ²Á¤¹¤ë¤È¡¢ ÇÛÎó¤¬Í×ÁǤò´Þ¤à¾ì¹ç¤«¤Ä¤½¤Î¾ì¹ç¤Ë¸Â¤ê¿¿¤ÎÃͤòÊÖ¤¹¡£ (Í×ÁǤ¬¤¢¤ë¾ì¹ç¤ËÊÖ¤ëÃͤÏʸ»úÎó¤Ç¡¢ »ÈÍѤ·¤Æ¤¤¤ë bucket ¤Î¿ô¤ª¤è¤Ó¥¢¥í¥±¡¼¥È¤µ¤ì¤Æ¤¤¤ë bucket ¤Î¿ô¤«¤é¤Ê¤ê¡¢ ¥¹¥é¥Ã¥·¥å¤Ç¶èÀÚ¤é¤ì¤Æ¤¤¤ë¡£)

¿¼¡¸µÇÛÎó¤ÏľÀܤϥµ¥Ý¡¼¥È¤·¤Æ¤¤¤Ê¤¤¤¬¡¢ Ï¢ÁÛÇÛÎó¤òÍѤ¤¤Æ Ê£¿ô¤Îź¤¨»ú¤ò¥¨¥ß¥å¥ì¡¼¥È¤¹¤ëÊýË¡¤Ë¤Ä¤¤¤Æ¤Ï $; ÊÑ¿ô¤Î¹à¤ò»²¾È¤Î¤³¤È¡£ ¤Þ¤¿¡¢Â¿¼¡¸µ¤Îź¤¨»ú¤ò 1 ¼¡¸µ¤Îź¤¨»ú¤ËÊÑ´¹¤¹¤ë¥µ¥Ö¥ë¡¼¥Á¥ó¤ò½ñ¤¯¤³¤È¤â¤Ç¤­¤ë¡£ See section @hbox{@hbox to 1.6em{@tt@$;@hfil} : ¿¼¡¸µÇÛÎ󥨥ߥå¥ì¡¼¥·¥ç¥ó¤ÎºÝ¤Îź¤¨»ú¤Î¶èÀÚ¤ê}.

³Æ¡¹¤Î¥Ç¡¼¥¿·¿¤Ë±þ¤¸¤Æ¡¢¤½¤ì¤¾¤ì¤Î̾Á°¶õ´Ö¤¬¤¢¤ë¡£ ¾×Æͤò¿´ÇÛ¤¹¤ë¤³¤È¤Ê¤¯¡¢Æ±¤¸Ì¾Á°¤ò¥¹¥«¥é¡¼ÊÑ¿ô¡¢ÇÛÎó¡¢Ï¢ÁÛÇÛÎó¡¢ ¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¡¢¥µ¥Ö¥ë¡¼¥Á¥ó̾¡¢¤Þ¤¿¤Ï¥é¥Ù¥ë¤Ë¤Ä¤±¤ë¤³¤È¤¬¤Ç¤­¤ë¡£

ÊÑ¿ô¤äÇÛÎó¤Ø¤Î»²¾È¤Ï¾ï¤Ë $¡¢@¡¢% ¤Ç»Ï¤Þ¤ë¤Î¤Ç¡¢ ͽÌó¸ì¤ÏÊÑ¿ô̾¤Ë¤Ä¤¤¤Æ¤Ï¼ÂºÝ¤Ë¤Ï»ÈÍѲÄǽ¤Ç¤¢¤ë¡£ (¤·¤«¤·¡¢¥é¥Ù¥ë¤ä¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤Ë¤Ä¤¤¤Æ¤ÏͽÌó¸ì¤Ï»ÈÍѤǤ­¤Ê¤¤¡£ Æüì¤Êʸ»ú¤Ç»Ï¤Þ¤é¤Ê¤¤¤«¤é¤Ç¤¢¤ë¡£ ¥Ò¥ó¥È: `open(log,'logfile')' ¤è¤ê `open(LOG,'logfile')' ¤ò »È¤Ã¤¿Êý¤¬Îɤ¤¡£ Âçʸ»ú¤Î¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë̾¤ò»È¤¦¤È¡¢Æɤ߰פµ¤â¸þ¾å¤·¡¢ ¾­ÍèͽÌ󤵤ì¤ëñ¸ì¤È¤Î¾×ÆͤâÈò¤±¤ë¤³¤È¤¬¤Ç¤­¤ë¡£)

Âçʸ»ú¾®Ê¸»ú¤Î¶èÊ̤ϽÅÍפǤ¢¤ë -- `FOO'¡¢`Foo'¡¢`foo' ¤Ï ¤¹¤Ù¤Æ°Û¤Ê¤ë̾Á°¤Ç¤¢¤ë¡£¥¢¥ë¥Õ¥¡¥Ù¥Ã¥È¤Ç»Ï¤Þ¤ë̾Á°¤Ï¿ô»ú¤ä²¼Àþ¤ò´Þ¤ó¤Ç¤â¤è¤¤¡£ ¥¢¥ë¥Õ¥¡¥Ù¥Ã¥È¤Ç»Ï¤Þ¤é¤Ê¤¤Ì¾Á°¤Ï 1 ʸ»ú¤Ë¸Â¤é¤ì¤ë¡£ Îã: `$%' ¤ä `$$'¡£ (¤Û¤È¤ó¤É¤Î°ìʸ»ú̾¤Ï perl ¤ÎͽÌóÊÑ¿ô¤È¤·¤Æ°ÕÌ£¤¬¤¢¤ë¡£ ͽÌóÊÑ¿ô¤Ë¤Ä¤¤¤Æ¤Ï See section ͽÌóÊÑ¿ô).

ʸ»úÎó¤Î°·¤¤

¿ôÃÍʸ»úÎó¤ÏÄ̾ï¤Î¾®¿ôÅÀ¤äÀ°¿ô¤Î·Á¼°¤Çɽ¤¹¡£

12345
12345.67
.23E-10
0xffff	# 16 ¿Ê
0377	#  8 ¿Ê
4_294_967_296

ʸ»úÎó¤Ï¥·¥ó¥°¥ë¥¯¥©¡¼¥È¤Þ¤¿¤Ï¥À¥Ö¥ë¥¯¥©¡¼¥È¤Ç¶èÀÚ¤é¤ì¤ë¡£ ¤³¤ì¤é¤Ï¥·¥§¥ë¤Ë¤ª¤±¤ë¥¯¥©¡¼¥È¤È¤è¤¯»÷¤Æ¤¤¤ë¡£ ¥À¥Ö¥ë¥¯¥©¡¼¥È¤Ç°Ï¤Þ¤ì¤¿Ê¸»úÎó¤Ë¤Ï¥Ð¥Ã¥¯¥¹¥é¥Ã¥·¥å¤äÊÑ¿ô¤ÎÃÖ´¹¤¬¹Ô¤ï¤ì¤ë¡£ ¥·¥ó¥°¥ë¥¯¥©¡¼¥È¤Ç°Ï¤Þ¤ì¤¿Ê¸»úÎó¤Ë¤Ï¹Ô¤ï¤ì¤Ê¤¤¡£( \' ¤È \\ ¤ò½ü¤¤¤Æ¡£)

Ä̾ï¤Î¥Ð¥Ã¥¯¥¹¥é¥Ã¥·¥åµ¬Â§¤¬²þ¹Ô¤ä¥¿¥Ö¤Ê¤É¤Îʸ»ú¤òɽ¤¹¤Î¤Ë»È¤¨¤ë¡£ ²Ã¤¨¤Æ°Ê²¼¤Î¤Á¤ç¤Ã¤ÈÊѤï¤Ã¤¿·Á¼°¤â»È¤¨¤ë¡£

\t      ¥¿¥Ö
\n      ²þ¹Ô
\r      ¥ê¥¿¡¼¥ó
\f      ¥Õ¥©¡¼¥à¥Õ¥£¡¼¥É
\b      ¥Ð¥Ã¥¯¥¹¥Ú¡¼¥¹
\a      ¥¢¥é¡¼¥à(¥Ù¥ë)
\e      ¥¨¥¹¥±¡¼¥×
\033    8 ¿Êʸ»ú
\x1b    16 ¿Êʸ»ú
\c[     ¥³¥ó¥È¥í¡¼¥ëʸ»ú
\l      ¼¡¤Îʸ»ú¤ò¾®Ê¸»ú¤Ë¤¹¤ë
\u      ¼¡¤Îʸ»ú¤òÂçʸ»ú¤Ë¤¹¤ë
\L      \E ¤Þ¤Ç¤ò¾®Ê¸»ú¤Ë¤¹¤ë
\U      \E ¤Þ¤Ç¤òÂçʸ»ú¤Ë¤¹¤ë
\E      Â羮ʸ»ú¤Î½¤¾þ¤Î½ª¤ê

²þ¹Ô¤òľÀÜʸ»úÎó¤Ë½ñ¤­Æþ¤ì¤ë¤³¤È¤â¤Ç¤­¤ë¡£ ¤¹¤Ê¤ï¤Á¡¢Ê¸»úÎó¤Ï»Ï¤Þ¤Ã¤¿¹Ô¤È°Û¤Ê¤ë¹Ô¤Ç½ª¤ï¤ë¤³¤È¤¬¤Ç¤­¤ë¡£ ¤³¤ì¤ÏÊØÍø¤Ç¤¢¤ë¤¬¡¢ºÇ¸å¤Ë¥¯¥©¡¼¥È¤ò˺¤ì¤ë¤È¡¢ ¥¯¥©¡¼¥È¤ò´Þ¤à¤«¤Ê¤êÎ¥¤ì¤¿Ê̤ιԤò¸«¤Ä¤±¤ë¤Þ¤Ç perl ¤Ï ¥¨¥é¡¼¤òÊó¹ð¤·¤Ê¤¤¤À¤í¤¦¡£

ʸ»úÎóÆâ¤ÎÊÑ¿ôÃÖ´¹¤Ï¥¹¥«¥é¡¼ÊÑ¿ô¡¦Ä̾ï¤ÎÇÛÎóÃÍ¡¦ÇÛÎó¤Î°ìÉô¤Ë¸Â¤é¤ì¤ë¡£ (¸À¤¤´¹¤¨¤ë¤È¡¢$ ¤ä @ ¤Ç»Ï¤Þ¤ë¼±Ê̻Ҥȡ¢ ¤½¤ì¤Ë³ç¸Ì¤Ç°Ï¤Þ¤ì¤¿Åº¤¨»ú¤¬¤¢¤ë¾ì¹ç¤À¤±¤Ç¤¢¤ë¡£) ¼¡¤Î¥³¡¼¥É¤Ï `The price is $100.' ¤ò½ÐÎϤ¹¤ë¡£

$Price = '$100'; # ²ò¼á¤µ¤ì¤Ê¤¤
print "The price is $Price.\n";# ²ò¼á¤µ¤ì¤ë

Ãí°Õ:
¸å¤Ë³¤¯¥¢¥ë¥Õ¥¡¥Ù¥Ã¥È¤ä¿ô»ú¤È¶èÊ̤¹¤ë¤¿¤á¤Ë¡¢ ¼±Ê̻Ҥò {} ¤Ç°Ï¤¦¤³¤È¤¬¤Ç¤­¤ë¡£ ¤Þ¤¿¡¢¥·¥ó¥°¥ë¥¯¥©¡¼¥È¤Ç°Ï¤Þ¤ì¤¿Ê¸»úÎó¤Ï ¤½¤ÎÁ°¤Îñ¸ì¤È¤Ï¥¹¥Ú¡¼¥¹¤Ç¶èÀÚ¤é¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£ ¤Ê¤¼¤Ê¤é¡¢¥·¥ó¥°¥ë¥¯¥©¡¼¥È¤Ï¼±Ê̻ҤȤ·¤ÆÍ­¸ú¤Êʸ»ú¤À¤«¤é¤Ç¤¢¤ë¡£ (See section ¥Ñ¥Ã¥±¡¼¥¸.)

Æüì¤Êʸ»úÎó¤¬Æó¤Ä¤¢¤ê¡¢__LINE__ ¤È __FILE__ ¤Ç¤¢¤ë¡£ ¤³¤ì¤Ï¥×¥í¥°¥é¥à¤Î¤½¤Î»þÅÀ¤Ç¤Î¹ÔÈÖ¹æ¤È¥Õ¥¡¥¤¥ë̾¤òɽ¤¹¡£ ¤³¤ì¤é¤ÏÆÈΩ¤·¤¿¥È¡¼¥¯¥ó¤È¤·¤Æ¤Î¤ß»ÈÍѤǤ­¤ë¡£ ʸ»úÎóÃæ¤Ë½ñ¤­Æþ¤ì¤ë¤³¤È¤Ï¤Ç¤­¤Ê¤¤¡£

¤µ¤é¤Ë¡¢__END__ ¤Ï¼ÂºÝ¤Î¥Õ¥¡¥¤¥ë¤Î½ªÎ»¤ÎÁ°¤Î ¥¹¥¯¥ê¥×¥È¤ÎÏÀÍýŪ¤Ê½ªÎ»¤ò¼¨¤¹¤Î¤Ë»È¤¨¤ë¡£ »Ä¤ê¤Î¥Æ¥­¥¹¥È¤ÏÁ´¤Æ̵»ë¤µ¤ì¤ë¤¬¡¢ ¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë DATA ¤«¤éÆɤळ¤È¤¬¤Ç¤­¤ë (DATA ¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤Ï¥á¥¤¥ó¤Î¥¹¥¯¥ê¥×¥È¤«¤é¤Î¤ß¥Ç¡¼¥¿¤òÆɤá¤ë¡£ require ¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¤äɾ²Á¤·¤¿Ê¸»úÎ󤫤é¤ÏÆɤá¤Ê¤¤)¡£ ^D ¤È ^Z ¤Î Æó¤Ä¤Î¥³¥ó¥È¥í¡¼¥ë¥­¥ã¥é¥¯¥¿¤Ï __END__ ¤ÈƱ¤¸°ÕÌ£¤Ç¤¢¤ë¡£

ʸˡŪ¤Ë²ò¼áÉÔ²Äǽ¤Êñ¸ì¤Ï ¤½¤ì¤¬¥·¥ó¥°¥ë¥¯¥©¡¼¥È¤Ç°Ï¤Þ¤ì¤Æ¤¤¤ë¤«¤Î¤è¤¦¤Ë°·¤ï¤ì¤ë¡£ ¤³¤Î¤¿¤á¡¢¥¢¥ë¥Õ¥¡¥Ù¥Ã¥È¡¦¿ô»ú¡¦²¼Àþ¤Î¤ß¤«¤é¤Ê¤ëñ¸ì¤Ï ¥¢¥ë¥Õ¥¡¥Ù¥Ã¥È¤Ç»Ï¤Þ¤é¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£ ¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤ä¥é¥Ù¥ë¤ÈƱ¤¸¤¯¡¢¾®Ê¸»ú¤Î¤ß¤«¤é¤Ê¤ëÍç¤Îñ¸ì¤Ï ¾­Íè¤ÎͽÌó¸ì¤È¾×Æͤ¹¤ë´í¸±¤¬¤¢¤ë¡£-w ¥¹¥¤¥Ã¥Á¤ò»È¤¨¤Ð¡¢ perl ¤Ï¤½¤Î¤è¤¦¤Êñ¸ì¤Ë¤Ä¤¤¤Æ·Ù¹ð¤¹¤ë¡£

ÇÛÎóÃͤò¥À¥Ö¥ë¥¯¥©¡¼¥È¤Ç°Ï¤Þ¤ì¤¿Ê¸»úÎó¤ËÆþ¤ì¤¿¾ì¹ç¤Ï¡¢ ÇÛÎó¤ÎÁ´Í×ÁǤò $" ¤Ç¼¨¤µ¤ì¤ë¶èÀÚ¤ê(¥Ç¥Õ¥©¥ë¥È¤Ï¥¹¥Ú¡¼¥¹) ¤Ç¶èÀڤäưì¤Ä¤Ë¤·¤¿Ê¸»úÎó¤Ë¤Ê¤ë¡£ See section @hbox{@hbox to 1.6em{@tt@$"@hfil} : ÇÛÎóÃͤò " " ¤Ç°Ï¤ó¤À»þ¤ËÍ×ÁÇ´Ö¤ËÆþ¤ë¥»¥Ñ¥ì¡¼¥¿}. (3.0 °ÊÁ°¤Î¥Ð¡¼¥¸¥ç¥ó¤Î perl ¤Ç¤Ï @ ¤Ï ¥á¥¿¥­¥ã¥é¥¯¥¿¡¼¤Ç¤Ï¤Ê¤«¤Ã¤¿¤Î¤Ç¡¢ @array¡¢$array[EXPR]¡¢@array[LIST]¡¢ $array{EXPR}¡¢@array{LIST} ¤Î²ò¼á¤Ï ¥×¥í¥°¥é¥à¤Î¤É¤³¤«¤Ç»²¾È¤µ¤ì¤Æ¤¤¤ë¤«¡¢ ͽ¤á define ¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤Î¤ß¹Ô¤ï¤ì¤ë¡£) ¼¡¤ÎÆó¤Ä¤ÏƱÅù¤Ç¤¢¤ë¡£

$temp = join($",@ARGV);
system "echo $temp";

system "echo @ARGV";

¸¡º÷¥Ñ¥¿¡¼¥ó(¤³¤ì¤Ë¤â¥À¥Ö¥ë¥¯¥©¡¼¥È¤ÈƱ¤¸ÃÖ´¹¤¬¹Ô¤ï¤ì¤ë)¤Ë¤ª¤¤¤Æ¤Ï¡¢ ¤¢¤¤¤Þ¤¤¤Ê¾ì¹ç¤¬¤¢¤ë¡£

/$foo[bar]/

¤Ï

/${foo}[bar]/ ([bar] ¤ÏÀµµ¬É½¸½¤Îʸ»ú¥¯¥é¥¹)

¤È¤·¤Æ²ò¼á¤¹¤ë¤Ù¤­¤«¡¢

/${foo[bar]}/ ([bar] ¤ÏÇÛÎó @foo ¤Îź¤¨»ú)

¤È¤·¤Æ²ò¼á¤¹¤ë¤Ù¤­¤« ?

@foo ¤¬Â¸ºß¤·¤Ê¤¤¤Ê¤é¤Ð¡¢ÌÀ¤é¤«¤Ëʸ»ú¥¯¥é¥¹¤Ç¤¢¤ë¡£ @foo ¤¬Â¸ºß¤¹¤ì¤Ð¡¢perl ¤Ï [bar] ¤Ë¤Ä¤¤¤Æ¤è¤¯¹Í¤¨¡¢ ¤½¤ÎÅú¤¨¤Ï¤Û¤È¤ó¤É¤Î¾ì¹çÀµ¤·¤¤¡£¤â¤·´Ö°ã¤Ã¤¿²ò¼á¤ò¤·¤¿¤ê¡¢ ¤¢¤ë¤¤¤Ï¤¢¤Ê¤¿¤¬Ã±¤ËÊм¹¶¸¤Ê¤é¤Ð¡¢ ¾å¤Ç½Ò¤Ù¤¿¤è¤¦¤Ë {} ¤òÆþ¤ì¤ë¤³¤È¤ÇÀµ¤·¤¤²ò¼á¤ò¤µ¤»¤ë¤³¤È¤¬¤Ç¤­¤ë¡£

¹Ôñ°Ì¤Î°úÍÑË¡

¹Ôñ°Ì¤Î°úÍÑË¡¤Ï¥·¥§¥ë¤ÎƱÍͤÎʸˡ¤Ë´ð¤Å¤¤¤Æ¤¤¤ë¡£ << ¤Î¸å¤Ë°úÍÑʸ¤Î½ª¤ï¤ê¤ò¼¨¤¹Ê¸»úÎó¤ò»ØÄꤹ¤ë¤È¡¢ ¸½ºß¹Ô¤«¤é¤½¤Îʸ»úÎ󤬸½¤ì¤ë¤Þ¤Ç¤Î¹ÔÁ´¤Æ¤¬¤½¤ÎÃͤˤʤ롣 ½ª¤ï¤ê¤ò¼¨¤¹Ê¸»úÎó¤Ï¼±Ê̻ҤǤ⡢°úÍѤ¹¤ë¥Æ¥­¥¹¥È¤Ç¤â¤è¤¤¡£ °úÍѤ¹¤ë¥Æ¥­¥¹¥È¤Î¾ì¹ç¡¢Ä̾ï¤Î¥¯¥©¡¼¥Æ¥£¥ó¥°¤ÈƱ¤¸¤¯ ¥¯¥©¡¼¥È¤Î¼ïÎब¥Æ¥­¥¹¥È¤Î°·¤¤Êý¤ò·è¤á¤ë¡£ ¥¯¥©¡¼¥È¤·¤Ê¤¤¼±Ê̻ҤϥÀ¥Ö¥ë¥¯¥©¡¼¥È¤ÈƱ¤¸¤è¤¦¤ËƯ¤¯¡£ (¥¹¥Ú¡¼¥¹¤òÆþ¤ì¤¿¾ì¹ç¡¢¤½¤ì¤Ï¥Ì¥ë¼±Ê̻ҤȤ·¤Æ°·¤ï¤ì¡¢¤³¤ì¤ÏÍ­¸ú¤Ç¡¢ ºÇ½é¤Î¥Ö¥é¥ó¥¯¥é¥¤¥ó¤Ë¥Þ¥Ã¥Á¤¹¤ë¡£--- ²¼¤Î Merry Christmas ¤ÎÎã¤ò¸«¤è¡£) ½ª¤ï¤ê¤ò¼¨¤¹Ê¸»úÎó¤Ï¤½¤ì¤À¤±¤Ç(¥¯¥©¡¼¥È¤ä¥¹¥Ú¡¼¥¹¤ò²ó¤ê¤Ë¤Ä¤±¤º) ¸ºß¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£

     print <<EOF;        # Á°¤ÎÎã¤ÈƱ¤¸
The price is $Price.
EOF

     print <<"EOF";      # ¾å¤ÎÎã¤ÈƱ¤¸
The price is $Price.
EOF

     print << x 10;      # ¥Ì¥ë¼±Ê̻Ҥ¬½ª¤ï¤ê¤ò¼¨¤¹Ê¸»úÎó
Merry Christmas!

     print <<`EOC`;      # ¥³¥Þ¥ó¥É¤ò¼Â¹Ô¤¹¤ë
echo hi there
echo lo there
EOC

     print <<foo, <<bar; # ¥¹¥¿¥Ã¥¯¤ËÀѤळ¤È¤¬¤Ç¤­¤ë
I said foo.
foo
I said bar.
bar

ÇÛÎó¤Îɽ¸½

ÇÛÎó¤Îɽ¸½¤Ï¡¢¸Ä¡¹¤ÎÃͤò¥³¥ó¥Þ¤Ç¶èÀڤꡢ³ç¸Ì () ¤Ç°Ï¤à:

(LIST)

ÇÛÎóÃͤòÍ׵ᤷ¤Ê¤¤¥³¥ó¥Æ¥­¥¹¥È¤Ç¤Ï¡¢C ¤Î¥³¥ó¥Þ±é»»»Ò¤ÈƱ¤¸¤¯¡¢ ºÇ¸å¤ÎÍ×ÁǤÎÃͤ¬ÇÛÎóɽ¸½¤ÎÃͤȤʤ롣Î㤨¤Ð¡¢

@foo = ('cc', '-E', $bar);

¤ÏÇÛÎó foo ¤ËÁ´ÇÛÎóÃͤòÂåÆþ¤¹¤ë¤¬¡¢

$foo = ('cc', '-E', $bar);

¤ÏÊÑ¿ô bar ¤ÎÃͤòÊÑ¿ô foo ¤ËÂåÆþ¤¹¤ë¡£

Ãí°Õ: ÊÑ¿ô¤È¤·¤Æ¸ºß¤¹¤ë(actual)ÇÛÎó¤Î¥¹¥«¥é¡¼¤Î¥³¥ó¥Æ¥­¥¹¥È¤Ë¤ª¤±¤ëÃÍ¤Ï ÇÛÎó¤ÎŤµ¤Ç¤¢¤ë¡£¼¡¤ÎÎã¤Ç¤Ï $foo ¤Ë 3 ¤òÂåÆþ¤¹¤ë¡£

@foo = ('cc', '-E', $bar);
$foo = @foo;		# $foo ¤Ï 3 ¤Ë¤Ê¤ë

ÇÛÎóɽ¸½¤Î³ç¸Ì¤òÊĤ¸¤ëÁ°¤Ë;ʬ¤Ê¥³¥ó¥Þ¤¬¤¢¤Ã¤Æ¤âÎɤ¤¡£ ¤Ä¤Þ¤ê¡¢°Ê²¼¤Îɽ¸½¤Ï²Äǽ¤Ç¤¢¤ë¡£

@foo = (
  1,
  2,
  3,
);

¥ê¥¹¥È¤¬É¾²Á¤µ¤ì¤ë»þ¤Ï¡¢ ¥ê¥¹¥È¤ÎÍ×ÁǤϤ¹¤Ù¤ÆÇÛÎó¤Î¥³¥ó¥Æ¥­¥¹¥È¤Çɾ²Á¤µ¤ì¡¢·ë²Ì¤È¤·¤ÆÆÀ¤é¤ì¤ëÇÛÎóÃͤϡ¢ ¸Ä¡¹¤ÎÍ×ÁǤ¬¥ê¥¹¥È¤Î¥á¥ó¥Ð¡¼¤Ç¤¢¤Ã¤¿¤«¤Î¤è¤¦¤Ë¥ê¥¹¥È¤ËÆþ¤ì¤é¤ì¤ë¡£ ¤Ä¤Þ¤ê¡¢ÇÛÎó¤Ï¥ê¥¹¥È¤Ë¤ª¤¤¤Æ¤Ï¶èÊ̤¬¤Ê¤¯¤Ê¤ë¡£¥ê¥¹¥È

        (@foo,@bar,&SomeSub)

¤Ï @foo, @bar ¤ÎÁ´Í×ÁÇ ¤ª¤è¤Ó SomeSub ¤È¤¤¤¦Ì¾Á°¤Î¥µ¥Ö¥ë¡¼¥Á¥ó¤¬ÊÖ¤¹Á´Í×ÁǤò´Þ¤à¡£

¥ê¥¹¥È¤ÎÃͤÏÄ̾ï¤ÎÇÛÎó¤ÈƱÍͤËź¤¨»ú¤ò¤Ä¤±¤Æ»ØÄê¤Ç¤­¤ë¡£

$time = (stat($file))[8];	# stat ¤ÏÇÛÎóÃͤòÊÖ¤¹
$digit = ('a','b','c','d','e','f')[$digit-10];
return (pop(@foo),pop(@foo))[0];

ÇÛÎó¤Î¥ê¥¹¥È¤Ï¤½¤ÎÍ×ÁǤ¬Á´¤Æº¸ÊÕÃͤǤ¢¤ê¡¢ ¤«¤Ä¤½¤Î»þ¤Ë¤«¤®¤êÂåÆþ²Äǽ¤Ç¤¢¤ë¡£

($a, $b, $c) = (1, 2, 3);

($map{'red'}, $map{'blue'}, $map{'green'}) = (0x00f, 0x0f0, 0xf00);

ºÇ¸å¤ÎÍ×ÁǤÏÇÛÎóËô¤ÏÏ¢ÁÛÇÛÎó¤Ç¤¢¤Ã¤Æ¤â¤è¤¤¡£

        ($a, $b, @rest) = split;
        local($a, $b, %rest) = @_;

¼ÂºÝ¤Ë¤Ï¥ê¥¹¥È¤Î¤É¤³¤ËÇÛÎó¤òÆþ¤ì¤Æ¤â¤¤¤¤¤Î¤À¤¬¡¢ ¥ê¥¹¥ÈÃæ¤ÎºÇ½é¤ÎÇÛÎó¤¬Á´¤Æ¤ÎÃͤò¼è¤Ã¤Æ¤·¤Þ¤¤¡¢ ¤½¤Î¸å¤ÎÍ×ÁǤˤϥ̥ëÃͤ¬Æþ¤Ã¤Æ¤·¤Þ¤¦¡£ ¤³¤ì¤Ï local() ¤Ë¤ª¤¤¤ÆÊØÍø¤«¤â¤·¤ì¤Ê¤¤¡£(See section local.)

Ï¢ÁÛÇÛÎó¤Îɽ¸½¤Ï¡¢¥­¡¼¡¢ÃͤȤ·¤Æ²ò¼á¤µ¤ì¤ë¤Ù¤­ÃͤΥڥ¢¤ò´Þ¤à¡£

# ¾åµ­¤Î map ¤Ø¤ÎÂåÆþ¤ÈƱ¤¸¡£
%map = ('red',0x00f,'blue',0x0f0,'green',0xf00);

¥¹¥«¥é¡¼¤Î¥³¥ó¥Æ¥­¥¹¥È¤Ç¤ÎÇÛÎó¤ÎÂåÆþ¤Ï ÂåÆþ¤Î±¦ÊդΠexpression ¤Ë¤è¤êÆÀ¤é¤ì¤ëÍ×ÁǤοô¤òÊÖ¤¹¡£

$x = (($foo,$bar) = (3,2,1)); # $x ¤ò 2 ¤Ç¤Ï¤Ê¤¯ 3 ¤Ë¥»¥Ã¥È¤¹¤ë

¥³¥Þ¥ó¥É¤Î½ÐÎÏ

ʸ»úÎó¤ò " ¤Ç°Ï¤ó¤À¾ì¹ç¡¢ ¤Þ¤º¥À¥Ö¥ë¥¯¥©¡¼¥È¤ÈÁ´¤¯Æ±¤¸ÊÑ¿ôÃÖ´¹¤¬¹Ô¤ï¤ì¤ë¡£¼¡¤Ë¥·¥§¥ë¤Î¾ì¹ç¤ÈƱ¤¸¤¯¡¢ ¥³¥Þ¥ó¥É¤Ç¤¢¤ë¤È²ò¼á¤µ¤ì¡¢¤½¤Î¥³¥Þ¥ó¥É¤Î½ÐÎϤ¬¤³¤Îµ¼»÷ɽ¸½¤ÎÃͤȤʤ롣

¥¹¥«¥é¡¼¤Î¥³¥ó¥Æ¥­¥¹¥È¤Ç¤Ï¡¢Á´½ÐÎϤ¬Æþ¤Ã¤¿ 1 ¤Ä¤Îʸ»úÎó¤¬Ê֤롣

ÇÛÎó¤Î¥³¥ó¥Æ¥­¥¹¥È¤Ç¤Ï¡¢½ÐÎϤΠ1 ¹Ô¤ò 1 Í×ÁǤȤ·¤¿ÇÛÎóÃͤ¬Ê֤롣 (¾¤Î¹Ô¥¿¡¼¥ß¥Í¡¼¥¿¤ò»È¤¦¾ì¹ç¤Ë¤Ï $/ ¤ò¥»¥Ã¥È¤¹¤ë¡£)See section @hbox{@hbox to 1.6em{@tt@$/@hfil} : ÆþÎϥ쥳¡¼¥É¤Î¥»¥Ñ¥ì¡¼¥¿}.

¥³¥Þ¥ó¥É¤Ïµ¼»÷ɽ¸½¤¬É¾²Á¤µ¤ì¤ë¤¿¤Ó¤Ë¼Â¹Ô¤µ¤ì¤ë¡£ ¥³¥Þ¥ó¥É¤Î¥¹¥Æ¡¼¥¿¥¹¤Ï $? ¤ËÊ֤롣(See section @hbox{@hbox to 1.6em{@tt@$?@hfil} : ¥Ñ¥¤¥×¤Î¥¯¥í¡¼¥º¡¢system ´Ø¿ô¤Ê¤É¤ÇÊ֤ä¿¥¹¥Æ¡¼¥¿¥¹}.)

csh ¤Î¾ì¹ç¤È¤Ï°Û¤Ê¤ê¡¢ Ê֤äƤ¯¤ë¥Ç¡¼¥¿¤Ë¤ÏÃÖ´¹¤Ï°ìÀÚ¹Ô¤ï¤ì¤Ê¤¤¡£ -- ²þ¹Ô¤Ï²þ¹Ô¤Î¤Þ¤Þ¤Ç¤¢¤ë¡£ ¤É¤Î¥·¥§¥ë¤È¤â°Û¤Ê¤ê¡¢ ¥·¥ó¥°¥ë¥¯¥©¡¼¥È¤Ç°Ï¤ó¤Ç¤â¥³¥Þ¥ó¥ÉÆâ¤ÎÊÑ¿ô̾¤ÏÊÑ´¹¤µ¤ì¤Æ¤·¤Þ¤¦¡£ $ ¤ò¥·¥§¥ë¤ËÅϤ¹¤Ë¤Ï¡¢¥Ð¥Ã¥¯¥¹¥é¥Ã¥·¥å¤ò»È¤¦É¬Íפ¬¤¢¤ë¡£

¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë/¥Õ¥¡¥¤¥ë̾ÃÖ´¹

<> ¤Ç°Ï¤ó¤À¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤òɾ²Á¤¹¤ë¤È¡¢ ¤½¤Î¥Õ¥¡¥¤¥ë¤«¤é¼¡¤Î¹Ô¤òÆɤ߹þ¤à (²þ¹Ô¤ò´Þ¤à¤Î¤Ç¡¢EOF ¤Þ¤Ç¤Ïµ¶¤Ë¤Ê¤é¤Ê¤¤¡£ EOF ¤Î¾ì¹ç¤ÏÃͤȤ·¤Æ undefined ¤¬ÊÖ¤ë)¡£ Ä̾ï¤Ï¤½¤ÎÃͤòÊÑ¿ô¤ËÂåÆþ¤¹¤ëɬÍפ¬¤¢¤ë¤¬¡¢ °ì¤Ä¤À¤±¼«Æ°Åª¤ËÂåÆþ¤¬¹Ô¤ï¤ì¤ë¾õ¶·¤¬¤¢¤ë¡£ <¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë> ¤Î¤ß¤¬ while ¥ë¡¼¥×¤Î¾ò·ï¤Ç¤¢¤ë¾ì¹ç¤Ï¡¢ (¤½¤·¤Æ¤³¤Î¾ì¹ç¤Ë¤«¤®¤ê)ÃͤÏÊÑ¿ô $_ ¤Ë¼«Æ°Åª¤ËÂåÆþ¤µ¤ì¤ë¡£ (´ñ̯¤Ë»×¤¦¤«¤âÃΤì¤Ê¤¤¤¬¡¢ ¤³¤ì¤ò¤Û¤È¤ó¤É¤Î perl ¥¹¥¯¥ê¥×¥È¤Ë¤ª¤¤¤Æ»È¤¦¤Ç¤¢¤í¤¦¡£) ¤È¤Ë¤«¤¯¡¢¼¡¤ÎÎã¤ÏÁ´¤ÆƱÅù¤Ç¤¢¤ë¡£

while ($_ = <STDIN>) { print; }
while (<STDIN>) { print; }
for (;<STDIN>;) { print; }
print while $_ = <STDIN>;
print while <STDIN>;

¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë STDIN¡¢STDOUT¡¢STDERR ¤Ï ͽÌ󤵤ì¤Æ¤¤¤ë¡£(stdin¡¢stdout¡¢stderr ¤Ç¤âÆ°ºî¤¹¤ë¤¬¡¢ ¥Ñ¥Ã¥±¡¼¥¸¤ÎÃæ¤Ç¤Ï¥°¥í¡¼¥Ð¥ë¤Ç¤Ï¤Ê¤¯¥í¡¼¥«¥ë¤Ê¼±Ê̻ҤȤ·¤Æ²ò¼á¤µ¤ì¤ë¤Î¤Ç¡¢ Ư¤«¤Ê¤¤¡£)

¤³¤ì¤é°Ê³°¤Î¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤Ï open ´Ø¿ô¤òÍѤ¤¤ÆºîÀ®¤¹¤ë¡£ (See section open.)

<¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë> ¤òÇÛÎó¤òÍ׵᤹¤ë¥³¥ó¥Æ¥­¥¹¥È¤ÇÍѤ¤¤ë¤È¡¢ Á´ÆþÎϹԤΠ1 ¹Ô¤¬¤½¤ì¤¾¤ì 1 Í×ÁǤȤʤëÇÛÎó¤¬Ê֤롣 ¤³¤ÎÊýË¡¤ò»È¤¦¤È´Êñ¤ËµðÂç¤Ê¥Ç¡¼¥¿¶õ´Ö¤òºî¤ë¤³¤È¤¬¤Ç¤­¤ë¤Î¤Ç¡¢ Ãí°Õ¤·¤Æ»È¤Ã¤¿Êý¤¬¤¤¤¤¡£

¥Ì¥ë¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë <> ¤ÏÆüì¤Ç¡¢ sed ¤ä awk ¤ÎÆ°ºî¤ò¥¨¥ß¥å¥ì¡¼¥È¤¹¤ë¤Î¤ËÍѤ¤¤ë¡£ <> ¤Ë¤Ï¡¢É¸½àÆþÎϤ«¡¢ ¤Þ¤¿¤Ï¥³¥Þ¥ó¥É¥é¥¤¥ó¤Ë¥ê¥¹¥È¥¢¥Ã¥×¤·¤¿Á´¥Õ¥¡¥¤¥ë¤«¤éÆþÎϤµ¤ì¤ë¡£ ¤³¤ì¤Ï¼¡¤Î¤è¤¦¤ËÆ°ºî¤¹¤ë¡£

<> ¤òºÇ½é¤Ëɾ²Á¤¹¤ë¤È¡¢ÇÛÎó ARGV ¤¬¥Á¥§¥Ã¥¯¤µ¤ì¡¢ ¥Ì¥ë¤Ç¤¢¤ì¤Ð¡¢$ARGV[0] ¤¬ `-' ¤Ë¥»¥Ã¥È¤µ¤ì¤ë¡£ ¤³¤ì¤Ï¡¢¥ª¡¼¥×¥ó¤¹¤ë»þ¤Ëɸ½àÆþÎϤȤʤ롣 ¼¡¤ËÇÛÎó ARGV ¤¬¥Õ¥¡¥¤¥ë̾¤Î¥ê¥¹¥È¤È¤·¤Æ½èÍý¤µ¤ì¤ë¡£¼¡¤Î¥ë¡¼¥×

while (<>) {
     ...            # ³Æ¹Ô¤ËÂФ¹¤ë¥³¡¼¥É
}

¤Ï¼¡¤Î perl Ūµ¿»÷¥³¡¼¥É¤ÈƱÅù¤Ç¤¢¤ë¡£

unshift(@ARGV, '-') if $#ARGV < $[;
while ($ARGV = shift) {
     open(ARGV, $ARGV);
     while (<ARGV>) {
          ...      # ³Æ¹Ô¤ËÂФ¹¤ë¥³¡¼¥É
     }
}

°ã¤¤¤Ï¡¢Á°¼Ô¤Ï¸å¼Ô¤Û¤É½ñ¤¯¤Î¤¬ÌÌÅݤǤʤ¯¡¢¤«¤Ä¼ÂºÝ¤ËÆ°¤¯¤È¤¤¤¦ÅÀ¤Ç¤¢¤ë¡£ Á°¼Ô¤Ç¤â¼ÂºÝ¤ËÇÛÎó ARGV ¤ò¥·¥Õ¥È¤·¡¢ ¸½ºß¤Î¥Õ¥¡¥¤¥ë̾¤ò $ARGV ¤ËÂåÆþ¤·¤Æ¤¤¤ë¡£ ¤Þ¤¿¡¢¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë ARGV ¤â ÆâÉô¤ÇÍѤ¤¤Æ¤¤¤ë -- <> ¤Ï <ARGV> ¤ÈÁ´¤¯Æ±¤¸°ÕÌ£¤Ç¤¢¤ê¡¢ ¤³¤ì¤â¡ÖËâË¡¡×¤Î¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤Ç¤¢¤ë (¾å¤Îµ¿»÷¥³¡¼¥É¤¬Æ°¤«¤Ê¤¤¤Î¤Ï¡¢ <ARGV> ¤òÉáÄ̤Υե¡¥¤¥ë¥Ï¥ó¥É¥ë¤Î¤è¤¦¤Ë°·¤Ã¤Æ¤¤¤ë¤«¤é¤Ç¤¢¤ë)¡£

ɬÍפʥե¡¥¤¥ë̾¤Î¥ê¥¹¥È¤ò´Þ¤à¤è¤¦¤Ë¤·¤Æ¤ª¤¯¤«¤®¤ê¡¢ ºÇ½é¤Î <> ¤ÎÁ°¤Ç @ARGV ¤Ë¼ê¤ò²Ã¤¨¤ë¤³¤È¤¬¤Ç¤­¤ë¡£ ¹ÔÈÖ¹æ ($.) ¤ÏÆþÎϤ¬°ì¤Ä¤ÎÂ礭¤Ê¥Õ¥¡¥¤¥ë¤Ç¤¢¤ë¤Î¤ÈƱ¤¸¤¯¡¢ ·Ñ³¤·¤ÆÁý¤¨¤ë¡£ (¥Õ¥¡¥¤¥ëËè¤Ë¹ÔÈÖ¹æ¤ò¥ê¥»¥Ã¥È¤¹¤ëÊýË¡¤Ë¤Ä¤¤¤Æ¤Ï eof ¤ÎÎã¤ò»²¾È¤Î¤³¤È¡£ See section eof.)

@ARGV ¤Ë¥Õ¥¡¥¤¥ë¤Î¥ê¥¹¥È¤ò¥»¥Ã¥È¤·¤¿¤¤¾ì¹ç¤Ï¡¢¤½¤¦¤¹¤ì¤Ð¤è¤¤¡£ ¥¹¥¯¥ê¥×¥È¤Ë¥¹¥¤¥Ã¥Á¤òÅϤ·¤¿¤¤¾ì¹ç¤Ï¡¢ ºÇ½é¤Ë¼¡¤Î¤è¤¦¤Ê¥ë¡¼¥×¤òÆþ¤ì¤ì¤Ð¤è¤¤¡£

while ($_ = $ARGV[0], /^-/) {
     shift;
    last if /^--$/;
     /^-D(.*)/ && ($debug = $1);
     /^-v/ && $verbose++;
     ...       # ¤Û¤«¤Î¥¹¥¤¥Ã¥Á
}
while (<>) {
     ...       # ³Æ¹Ô¤ËÂФ¹¤ë¥³¡¼¥É
}

<> ¤Ï°ìÅÙ¤À¤±µ¶¤òÊÖ¤¹¡£¤³¤Î¸å¤â¤¦°ìÅٸƤ֤ȡ¢ ¿·¤¿¤Ê @ARGV ¥ê¥¹¥È¤Î½èÍý¤ò¹Ô¤Ã¤Æ¤¤¤ë¤â¤Î¤È¸«¤Ê¤¹¡£ ¤½¤·¤Æ¤³¤Î»þ @ARGV ¤ò ¥»¥Ã¥È¤·¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï STDIN ¤«¤éÆþÎϤµ¤ì¤ë¡£

<> ¤ÎÃæ¤Îʸ»úÎ󤬥¹¥«¥é¡¼ÊÑ¿ô¤ò»²¾È¤·¤Æ¤¤¤ë¾ì¹ç (Î㤨¤Ð <$foo>)¡¢¤½¤ÎÊÑ¿ô¤Ï ÆþÎϤ¬¹Ô¤ï¤ì¤ë¤Ù¤­¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤Î̾Á°¤òÃͤȤ·¤Æ»ý¤Ä¡£

<> ¤ÎÃæ¤Îʸ»úÎ󤬥ե¡¥¤¥ë¥Ï¥ó¥É¥ë¤Ç¤Ê¤¤¾ì¹ç¤Ï¡¢ ÃÖ´¹¤µ¤ì¤ë¤Ù¤­¥Õ¥¡¥¤¥ë̾¥Ñ¥¿¡¼¥ó¤Ç¤¢¤ë¤È²ò¼á¤µ¤ì¡¢ ¥³¥ó¥Æ¥­¥¹¥È¤Ë¤è¤ê¥Õ¥¡¥¤¥ë̾¤ÎÇÛÎó¤Þ¤¿¤Ï¥ê¥¹¥ÈÆâ¤Î¼¡¤Î¥Õ¥¡¥¤¥ë̾¤¬Ê֤롣 1 ¥ì¥Ù¥ë¤Î $ ¤Î²ò¼á¤ÏºÇ½é¤Ë¤Ê¤µ¤ì¤ë¤¬¡¢ ¾å¤Ç½Ò¤Ù¤¿¤è¤¦¤Ë <$foo> ¤Ï ´ÖÀÜŪ¤Ë¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤ò»Ø¤¹¤Î¤Ç»È¤¨¤Ê¤¤¡£ ¶¯À©Åª¤Ë¥Õ¥¡¥¤¥ë̾ÃÖ´¹¤È²ò¼á¤µ¤»¤ë¤¿¤á¤Ë¤Ï¡¢ {} ¤òÆþ¤ì¤ì¤Ð¤è¤¤: <${foo}>¡£

while (<*.c>) {
     chmod 0644, $_;
}

¤Ï¼¡¤ÈƱÅù¤Ç¤¢¤ë¡£

open(foo, "echo *.c | tr -s ' \t\r\f' '\\012\\012\\012\\012'|");
while (<foo>) {
     chop;
     chmod 0644, $_;
}

¼Â¤Ï¡¢¸½ºß¤Î½ê¡¢¸å¼Ô¤ÎÊýË¡¤Ç¥¤¥ó¥×¥ê¥á¥ó¥È¤·¤Æ¤¤¤ë¡£ (¤Ä¤Þ¤ê¡¢¥Þ¥·¥ó¾å¤Ë `/bin/csh' ¤¬¤Ê¤¤¤«¤®¤ê ¥¹¥Ú¡¼¥¹¤Ê¤É¤ò´Þ¤à¥Õ¥¡¥¤¥ë̾¤Ë¤Ä¤¤¤Æ¤Ï¤¦¤Þ¤¯Æ¯¤«¤Ê¤¤¡£) ¤â¤Á¤í¤ó¡¢¾å¤ÎÁàºî¤ò¹Ô¤¦ºÇ¤âû¤¤ÊýË¡¤Ï

chmod 0644, <*.c>;

¤Ç¤¢¤ë¡£

ʸˡ

perl ¥¹¥¯¥ê¥×¥È¤Ï°ìÏ¢¤ÎÀë¸À¤È¥³¥Þ¥ó¥É¤«¤é¤Ê¤ë¡£ perl ¤Ë¤ª¤¤¤ÆÀë¸À¤¹¤ëɬÍפ¬¤¢¤ë¤Î¤Ï ¥ì¥Ý¡¼¥È¡¦¥Õ¥©¡¼¥Þ¥Ã¥È¤È¥µ¥Ö¥ë¡¼¥Á¥ó¤À¤±¤Ç¤¢¤ë¡£

¤³¤ì¤é¤Ë¤Ä¤¤¤Æ¤Ï¤½¤ì¤¾¤ì¥Õ¥©¡¼¥Þ¥Ã¥È¡¢¥µ¥Ö¥ë¡¼¥Á¥ó¤Î¾Ï¤ò»²¾È¤Î¤³¤È¡£ See section ¥Õ¥©¡¼¥Þ¥Ã¥È, ¤ª¤è¤Ó See section ¥µ¥Ö¥ë¡¼¥Á¥ó.

¥æ¡¼¥¶¤¬ºîÀ®¤·¤¿½é´ü²½¤µ¤ì¤Æ¤¤¤Ê¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Ï ÂåÆþ¤Ê¤É¤ÎÌÀ¼¨Åª¤ÊÁàºî¤¬¹Ô¤ï¤ì¤ë¤Þ¤ÇÁ´¤Æ¥Ì¥ë¤Þ¤¿¤Ï 0 ¤È¤Ê¤ë¡£ ¥³¥Þ¥ó¥É·²¤¬ÆþÎϹÔÁ´¤Æ¤Ë¤Ä¤¤¤Æ¼Â¹Ô¤µ¤ì¤ë sed ¤ä awk ¤È¤Ï°ã¤Ã¤Æ¡¢ ¥³¥Þ¥ó¥É·²¤Ï°ìÅÙ¤·¤«¼Â¹Ô¤µ¤ì¤Ê¤¤¡£ ¤³¤Î¤¿¤á¡¢ÆþÎÏ¥Õ¥¡¥¤¥ë¤Î³Æ¹Ô¤Ë¤Ä¤¤¤Æ·«¤êÊÖ¤·¤ò¹Ô¤¦¤Ë¤Ï ÌÀ¼¨Åª¤Ë¥ë¡¼¥×¤òÀߤ±¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤°ìÊý¡¢ ÃåÌܤ¹¤ë¥Õ¥¡¥¤¥ë¡¢¹Ô¤ò¤è¤ê¤è¤¯¥³¥ó¥È¥í¡¼¥ë¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£ (¼Â¤Ï¡¢Àµ¤·¤¯¤Ê¤¤... -n ¤ä -p ¥ª¥×¥·¥ç¥ó¤ò»È¤Ã¤Æ¡¢ ¼«Æ°Åª¤Ë¥ë¡¼¥×¤µ¤»¤ë¤³¤È¤¬²Äǽ¤Ç¤¢¤ë¡£ See section ¥³¥Þ¥ó¥É¥é¥¤¥ó¥ª¥×¥·¥ç¥ó.)

Àë¸Àʸ¤Ï¥³¥Þ¥ó¥É¤ò½ñ¤¯¤³¤È¤¬¤Ç¤­¤ë¾ì½ê¤Ê¤é¤É¤³¤Ë¤Ç¤â½ñ¤¯¤³¤È¤¬¤Ç¤­¡¢ ¥³¥Þ¥ó¥É¼Â¹Ô¤Î´ðËÜŪ¤Ê¥·¡¼¥±¥ó¥¹¤Ë¤Ï±Æ¶Á¤òÍ¿¤¨¤Ê¤¤¡£ ¤Ä¤Þ¤ê¡¢Àë¸À¤¬±Æ¶Á¤òÍ¿¤¨¤ë¤Î¤Ï¥³¥ó¥Ñ¥¤¥ë»þ¤À¤±¤Ç¤¢¤ë¡£ Ä̾ï¤ÏÁ´¤Æ¤ÎÀë¸À¤ò¥¹¥¯¥ê¥×¥È¤ÎºÇ½é¤«ºÇ¸å¤Î¤É¤Á¤é¤«¤Ë½ñ¤¯¡£

perl ¤Ï¡¢¤Û¤È¤ó¤É¡¢¥Õ¥ê¡¼¥Õ¥©¡¼¥à¤Î¸À¸ì¤Ç¤¢¤ë¡£ (Í£°ì¤ÎÎã³°¤Ï¥Õ¥©¡¼¥Þ¥Ã¥È¤ÎÀë¸À¤Ç¤¢¤ë¤¬¡¢¤½¤ÎÍýͳ¤ÏÌÀÇò¤Ç¤¢¤ë¡£)

¥³¥á¥ó¥È¤Ïʸ»ú # ¤«¤é¹Ô¤Î½ª¤ï¤ê¤Þ¤Ç¤Ç¤¢¤ë¡£ C ¤Î¥³¥á¥ó¥È /* */ ¤ò»È¤¦¤È¡¢ ¥³¥ó¥Æ¥­¥¹¥È¤Ë¤è¤ê³ä¤ê»»¤â¤·¤¯¤Ï¥Ñ¥¿¡¼¥ó¥Þ¥Ã¥Á¥ó¥°¤Ç¤¢¤ë¤È²ò¼á¤µ¤ì¤ë¤Î¤Ç¡¢ ÍѤ¤¤Ê¤¤¤è¤¦¤Ë¡£

Ê£¹çʸ

perl ¤Ë¤ª¤¤¤Æ¡¢¥³¥Þ¥ó¥É·²¤ò `{}' ¤Ç°Ï¤à¤È °ì¤Ä¤Î¥³¥Þ¥ó¥É¤È¤·¤Æ°·¤¦¤³¤È¤¬¤Ç¤­¤ë¡£¤³¤ì¤ò¥Ö¥í¥Ã¥¯¤È¸Æ¤Ö¡£

¼¡¤ÎÊ£¹ç¥³¥Þ¥ó¥É¤Ï¥Õ¥í¡¼¥³¥ó¥È¥í¡¼¥ë¤Î¤¿¤á¤ËÍѤ¤¤ë¡£

if (EXPR) BLOCK
if (EXPR) BLOCK else BLOCK
if (EXPR) BLOCK elsif (EXPR) BLOCK ... else BLOCK
LABEL while (EXPR) BLOCK
LABEL while (EXPR) BLOCK continue BLOCK
LABEL for (EXPR; EXPR; EXPR) BLOCK
LABEL foreach VAR (ARRAY) BLOCK
LABEL BLOCK continue BLOCK

Ãí°Õ¤¹¤Ù¤­¤³¤È¤Ï¡¢C ¤ä Pascal ¤È°ã¤¤¡¢¤³¤ì¤é¤Ïʸ(statement)¤Ç¤Ï¤Ê¤¯¡¢ ¥Ö¥í¥Ã¥¯¤È¤·¤ÆÀë¸À¤µ¤ì¤Æ¤¤¤ëÅÀ¤Ç¤¢¤ë¡£¤³¤Î¤¿¤á¡¢{} ¤¬É¬ÍפȤʤ롣 ¾ò·ïʸ¤ò {} ¤ò»È¤ï¤º¤Ë½ñ¤¯¤¿¤á¤Ë¤Ï¡¢¤¤¤¯¤Ä¤«ÊýË¡¤¬¤¢¤ë¡£ ¼¡¤ÎÎã¤ÏÁ´¤ÆƱ¤¸¤³¤È¤ò¤¹¤ë¡£

if (!open(foo)) { die "Can't open $foo: $!"; }
die "Can't open $foo: $!" unless open(foo);
open(foo) || die "Can't open $foo: $!"; # foo or bust!
open(foo) ? 'hi mom' : die "Can't open $foo: $!";
        # a bit exotic, that last one

if ʸ¤Ïñ½ã¤Ç¤¢¤ë¡£¥Ö¥í¥Ã¥¯¤Ïɬ¤º {} ¤Ç°Ï¤Þ¤ì¤Æ¤¤¤ë¤Î¤Ç¡¢ if ¤ä else ¤¬¤É¤³¤Ë¤«¤«¤ë¤«¤Ë¤Ä¤¤¤ÆÛ£Ëæ¤Ë¤Ê¤ë¤³¤È¤Ï¤Ê¤¤¡£ if ¤ÎÂå¤ï¤ê¤Ë unless ¤ò»È¤¦¾ì¹ç¡¢¥Æ¥¹¥È¤Î·ë²Ì¤¬µÕ¤Ë°·¤ï¤ì¤ë¡£

while ʸ¤Ï expression ¤¬¿¿(¥Ì¥ëʸ»úÎó¤ä 0 ¤Ç¤Ê¤¤)¤Ç¤¢¤ë´Ö¡¢ ¥Ö¥í¥Ã¥¯¤ò¼Â¹Ô¤¹¤ë¡£¥é¥Ù¥ë¤ò¤Ä¤±¤Æ¤â¤è¤¤¡£¥é¥Ù¥ë¤ò¤Ä¤±¤ë¾ì¹ç¡¢ ¤½¤Î¼±Ê̻Ҥθå¤Ë¥³¥í¥ó¤ò¤Ä¤±¤ë¡£ ¥é¥Ù¥ë¤Ï¥ë¡¼¥×¥³¥ó¥È¥í¡¼¥ëʸ next¡¢last¡¢redo ¤Î ¥ë¡¼¥×¤ò»ØÄꤹ¤ë(identifies the loop)(°Ê²¼¤ÎÎã¤ò»²¾È¡£)¡£ continue ¥Ö¥í¥Ã¥¯¤¬¤¢¤ì¤Ð¡¢¾ò·ïʸ¤òºÆɾ²Á¤¹¤ëľÁ°¤Ëɬ¤º¼Â¹Ô¤µ¤ì¤ë¡£ ¤³¤ì¤Ï for ¥ë¡¼¥×¤Î 3 ÈÖÌܤξò·ï¤ÈƱÍͤǤ¢¤ë¡£ ¤³¤Î¤¿¤á¡¢¤¿¤È¤¨¥ë¡¼¥×¤¬ next ʸ¤òÄ̤¸¤Æ³¹Ô¤µ¤ì¤ë¾ì¹ç¤Ç¤â¡¢ ¥ë¡¼¥×ÊÑ¿ô¤Î¥¤¥ó¥¯¥ê¥á¥ó¥È¤ò¹Ô¤¦¤¿¤á¤ËÍѤ¤¤ë¤³¤È¤¬¤Ç¤­¤ë¡£ (C ¤Î continue ʸ¤ÈƱÍÍ¡£)

while ¤ò until ¤ÇÃÖ¤­´¹¤¨¤ë¤È¡¢ ¥Æ¥¹¥È¤Î·ë²Ì¤¬µÕ¤Ë°·¤ï¤ì¤ë¤¬¡¢¾ò·ï¥Æ¥¹¥È¤Ï¥ë¡¼¥×¤ÎºÇ½é¤Ë¤â¹Ô¤ï¤ì¤ë¡£

if ʸ¤ä while ʸ¤Ë¤ª¤¤¤Æ¡¢ (EXPR) ¤ò¥Ö¥í¥Ã¥¯¤ÇÃÖ¤­´¹¤¨¤ë¤³¤È¤¬¤Ç¤­¤ë¡£ ¤³¤Î¾ì¹ç¡¢¾ò·ï¤Ï¥Ö¥í¥Ã¥¯¤ÎºÇ¸å¤Î¥³¥Þ¥ó¥É¤ÎÃͤ¬¿¿¤Ê¤é¤Ð¿¿¤È¤Ê¤ë¡£

for ¥ë¡¼¥×¤Ï ¤½¤ì¤ÈÂбþ¤¹¤ë while ¥ë¡¼¥×¤ÈÁ´¤¯Æ±ÍͤËÆ°ºî¤¹¤ë¡£

for ($i = 1; $i < 10; $i++) {
     ...
}

¤Ï¼¡¤ÈƱ¤¸¤Ç¤¢¤ë¡£

$i = 1;
while ($i < 10) {
     ...
} continue {
     $i++;
}

foreach ¥ë¡¼¥×¤ÏÄ̾ï¤ÎÇÛÎóÃͤˤĤ¤¤Æ¡¢ ½ç¤Ë¤½¤ÎÍ×ÁǤòÊÑ¿ô¤Ë¥»¥Ã¥È¤·¤Ê¤¬¤é·«¤êÊÖ¤·¤ò¹Ô¤¦¡£ ÊÑ¿ô¤Ï°ÅÌÛŪ¤Ë¥ë¡¼¥×¤Ë¥í¡¼¥«¥ë¤Ç¡¢¥ë¡¼¥×¤òÈ´¤±¤ë¤È¸µ¤ÎÃͤËÌá¤ë¡£

¼Â¤Ï¥­¡¼¥ï¡¼¥É foreach ¤Ï for ¤ÈÁ´¤¯Æ±¤¸¤â¤Î¤Ê¤Î¤Ç¡¢ Æɤ߰פµ¤Ç foreach¡¢´Ê·é¤µ¤Ç for ¤ò»È¤¦¤³¤È¤¬¤Ç¤­¤ë¡£

ÊÑ¿ô̾¤ò¾Êά¤¹¤ë¤È¡¢³Æ¡¹¤ÎÃÍ¤Ï $_ ¤Ë¥»¥Ã¥È¤µ¤ì¤ë¡£ ÇÛÎóÃͤ¬(ÇÛÎóÃͤòÊÖ¤¹ expression ¤Ç¤Ï¤Ê¤¯)¼ÂºÝ¤ÎÇÛÎó¤Î¾ì¹ç¤Ï¡¢ ¥ë¡¼¥×¤ÎÃæ¤ÇÊÑ¿ô¤òÊѹ¹¤¹¤ë¤³¤È¤ÇÇÛÎóÍ×ÁǤòÊѹ¹¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£Î㤨¤Ð:

for (@ary) { s/foo/bar/; }

foreach $elem (@elements) {
     $elem *= 2;
}

for ((10,9,8,7,6,5,4,3,2,1,'BOOM')) {
     print $_, "\n"; sleep(1);
}

for (1..15) { print "Merry Christmas\n"; }

foreach $item (split(/:[\\\n:]*/, $ENV{'TERMCAP'})) {
     print "Item: $item\n";
}

¥Ö¥í¥Ã¥¯¤Ï¤½¤ì¼«ÂÎ(¥é¥Ù¥ë¤¬¤Ä¤¤¤Æ¤¤¤Æ¤â¤¤¤Ê¤¯¤Æ¤â)¤¬ °ì²ó¤À¤±¼Â¹Ô¤µ¤ì¤ë¥ë¡¼¥×¤ÈƱ¤¸¤Ç¤¢¤ë¡£¤½¤³¤Ç¡¢¥Ö¥í¥Ã¥¯¤«¤éÈ´¤±¤¿¤ê¡¢ ¥Ö¥í¥Ã¥¯¤òºÆ¼Â¹Ô¤·¤¿¤ê¤¹¤ë¤Î¤Ë¥ë¡¼¥×¥³¥ó¥È¥í¡¼¥ëʸ¤ò»È¤¦¤³¤È¤¬¤Ç¤­¤ë¡£ continue ¥Ö¥í¥Ã¥¯¤â¤Ä¤±¤ë¤³¤È¤¬¤Ç¤­¤ë¡£ ¤³¤Î¤è¤¦¤Ê¹½À®¤Ï case ¹½Â¤¤òµ­½Ò¤¹¤ë¤Î¤ËÊØÍø¤Ç¤¢¤ë¡£

foo: {
     if (/^abc/) { $abc = 1; last foo; }
     if (/^def/) { $def = 1; last foo; }
     if (/^xyz/) { $xyz = 1; last foo; }
     $nothing = 1;
}

ƱÍͤΤ³¤È¤òµ­½Ò¤¹¤ëÊýË¡¤¬¤¤¤¯¤Ä¤«¤¢¤ë¤Î¤Ç¡¢ perl ¤Ë¤ÏÀµ¼°¤Ê switch ʸ¤Ï¤Ê¤¤¡£¾å¤ÎÎã¤ËÉÕ¤±²Ã¤¨¤ë¤È¡¢ ¼¡¤Î¤è¤¦¤Ë¤â½ñ¤±¤ë¡£

foo: {
     $abc = 1, last foo  if /^abc/;
     $def = 1, last foo  if /^def/;
     $xyz = 1, last foo  if /^xyz/;
     $nothing = 1;
}

¤Þ¤¿¤Ï

foo: {
     /^abc/ && do { $abc = 1; last foo; };
     /^def/ && do { $def = 1; last foo; };
     /^xyz/ && do { $xyz = 1; last foo; };
     $nothing = 1;
}

¤Þ¤¿¤Ï

foo: {
     /^abc/ && ($abc = 1, last foo);
     /^def/ && ($def = 1, last foo);
     /^xyz/ && ($xyz = 1, last foo);
     $nothing = 1;
}

¤µ¤é¤Ë¤Ï

if (/^abc/)
    { $abc = 1; }
elsif (/^def/)
    { $def = 1; }
elsif (/^xyz/)
    { $xyz = 1; }
else
    {$nothing = 1;}

¼ÂºÝ¤Ë¤Ï¤³¤ì¤é¤Ï¤¹¤Ù¤ÆÆâÉô¤Ç switch ¹½Â¤¤ËºÇŬ²½¤µ¤ì¤ë¤Î¤Ç¡¢ perl ¤ÏľÀÜÌÜŪ¤È¤¹¤ëʸ¤Ø¥¸¥ã¥ó¥×¤¹¤ë¡£ ¤À¤«¤é°ì¤Ä¤ÎƱ¤¸Ã±½ã¤Ê¥¹¥«¥é¡¼Ãͤò == ¤ä eq ¤ä ¾å¤Î¤è¤¦¤Ê¥Ñ¥¿¡¼¥ó¥Þ¥Ã¥Á¥ó¥°¤Ç¥Æ¥¹¥È¤¹¤ë¤«¤®¤ê¤Ë¤ª¤¤¤Æ¤Ï¡¢ elsif ¤¬ 50 ¤â¤¢¤Ã¤¿¤ê¤¹¤ë¤È¡¢ perl ¤¬ÉÔɬÍפÊʸ¤ò¤¿¤¯¤µ¤ó¼Â¹Ô¤¹¤ë¤Î¤Ç¤Ï¤Ê¤¤¤«¡¢¤È¤¤¤¦¿´ÇÛ¤ò¤¹¤ëɬÍפϤʤ¤¡£ (¤â¤·¡¢case ¥¹¥Æ¡¼¥È¥á¥ó¥È¤ËºÇŬ²½¤µ¤ì¤Æ¤¤¤ë¤«¤É¤¦¤«¤Ë¶½Ì£¤¬¤¢¤ë¤Ê¤é¡¢ -D1024 ¤òÍѤ¤¤Æ¼Â¹ÔÁ°¤Ë¥·¥ó¥¿¥Ã¥¯¥¹¥Ä¥ê¡¼¤òɽ¼¨¤µ¤»¤ë¤³¤È¤¬¤Ç¤­¤ë¡£)

ñʸ

ñʸ¤Î¤ß¤¬¤½¤ÎÉûºîÍѤòɾ²Á¤µ¤ì¤ë expression ¤Ç¤¢¤ë¡£ ñʸ¤Ï¡¢¥Ö¥í¥Ã¥¯¤ÎºÇ¸å¤Îʸ¤ò½ü¤¤¤Æ¡¢ ¤¹¤Ù¤Æ¥»¥ß¥³¥í¥ó¤Ç½ª¤ï¤é¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£ ¥Ö¥í¥Ã¥¯¤ÎºÇ¸å¤Îʸ¤Ç¤Ï¥»¥ß¥³¥í¥ó¤Ï¤¢¤Ã¤Æ¤â¤Ê¤¯¤Æ¤â¤è¤¤¡£ (¤·¤«¤·¡¢ ¥Ö¥í¥Ã¥¯¤¬ 2 ¹Ô°Ê¾å¤«¤é¤Ê¤ë¾ì¹ç¤Ë¤Ï¤ä¤Ï¤ê¥»¥ß¥³¥í¥ó¤ò¤Ä¤±¤ë¤³¤È¤¬Ë¾¤Þ¤·¤¤¡£)

ñʸ¤ÏÁ´¤Æ½¤¾þ»Ò¤ò°ì¤Ä¡¢½ªÎ»¤ò¼¨¤¹¥»¥ß¥³¥í¥ó¤ÎľÁ°¤Ë¤Ä¤±¤ë¤³¤È¤¬¤Ç¤­¤ë¡£ °Ê²¼¤Î¤â¤Î¤¬½¤¾þ»Ò¤È¤·¤Æ»ÈÍѲÄǽ¤Ç¤¢¤ë¡£

if EXPR
unless EXPR
while EXPR
until EXPR

if ¤ä unless ½¤¾þ»Ò¤Ï¸«³Ý¤±Ä̤ê¤Î°ÕÌ£¤ò»ý¤Ä¡£

while ¤ä until ½¤¾þ»Ò¤â¤Þ¤¿¸«³Ý¤±Ä̤ê¤Î°ÕÌ£¤ò¤â¤Ä (¾ò·ï¤ÏºÇ½é¤Ëɾ²Á¤µ¤ì¤ë)¤¬¡¢ do-¥Ö¥í¥Ã¥¯ ¤Þ¤¿¤Ï do-¥µ¥Ö¥ë¡¼¥Á¥ó ¥³¥Þ¥ó¥É¤ËŬÍѤµ¤ì¤¿¾ì¹ç¤Ï°Û¤Ê¤ë¡£ ¤³¤Î¾ì¹ç¡¢¾ò·ïʸ¤òɾ²Á¤¹¤ëÁ°¤Ë¥Ö¥í¥Ã¥¯¤ò°ì²ó¼Â¹Ô¤¹¤ë¡£ ¤³¤ì¤Ï¼¡¤Î¤è¤¦¤Ê¥ë¡¼¥×¤ò½ñ¤¯¤³¤È¤ò²Äǽ¤Ë¤¹¤ë¤¿¤á¤Ç¤¢¤ë¡£

do {
     $_ = <STDIN>;
     ...
} until $_ eq ".\n";

(do ±é»»»Ò¤Î¹à¤ò»²¾È¡£¤Þ¤¿¡¢¤³¤Î¾ì¹ç¤Ï¡¢ ¥ë¡¼¥×¥³¥ó¥È¥í¡¼¥ë¥³¥Þ¥ó¥É¤Ï»È¤¨¤Ê¤¤¡£¤Ê¤¼¤Ê¤é¡¢ ½¤¾þ»Ò¤Ï¥ë¡¼¥×¥é¥Ù¥ë¤ò»ý¤Ä¤³¤È¤¬¤Ç¤­¤Ê¤¤¤«¤é¤Ç¤¢¤ë¡£¤¢¤·¤«¤é¤º¡£)See section do.

±é»»»Ò & ´Ø¿ô

»Ø¿ô

`**'
»Ø¿ô±é»»»Ò¡£
`**='
»Ø¿ô±é»» & ÂåÆþ±é»»»Ò¡£

¥Ì¥ë¥ê¥¹¥È

`()'
ÇÛÎó¤ò½é´ü²½¤¹¤ë¤¿¤á¤Ë»È¤¦¡¢¥Ì¥ë¥ê¥¹¥È¡£

ʸ»úÎó·ë¹ç

`.'
2 ¤Ä¤Îʸ»úÎó¤Î·ë¹ç±é»»»Ò¡£
`.='
·ë¹ç & ÂåÆþ±é»»»Ò¡£

Èæ³Ó±é»»»Ò

`eq'
ʸ»úÎó¤ÎƱÃÍÀ­( == ¤Ï¿ôÃͤÎƱÃÍÀ­)¡£ (¤â¤·¡¢¾õ¶·¤Ë±þ¤¸¤Æ == ¤¬ ʸ»úÎ󤪤è¤Ó¿ôÃͤÎξÊý¤ÎƱÃÍÀ­¤òɽ¤¹ awk ¤Ë´·¤ì¤Æ¤¤¤ë¤Ê¤é¡¢Ãí°Õ¤»¤è!)
`ne'
ʸ»úÎó¤ÎÈóƱÃÍÀ­( != ¤Ï¿ôÃͤÎÈóƱÃÍÀ­)¡£
`lt'
ʸ»úÎó¤Î less than ¡£
`gt'
ʸ»úÎó¤Î greater than ¡£
`le'
ʸ»úÎó¤Î less than or equal ¡£
`ge'
ʸ»úÎó¤Î greater than or equal ¡£
`cmp'
ʸ»úÎó¤ÎÈæ³Ó¡£-1¡¢0¡¢¤Þ¤¿¤Ï 1 ¤òÊÖ¤¹¡£
`<=>'
¿ôÃͤÎÈæ³Ó¡£-1¡¢0¡¢¤Þ¤¿¤Ï 1 ¤òÊÖ¤¹¡£

ÁàºîÂоÝʸ»úÎó¤Î»ØÄê

`=~'
±é»»¤Ë¤Ï¡¢¸¡º÷¡¦Êѹ¹¤ò¥Ç¥Õ¥©¥ë¥È¤Çʸ»úÎó $_ ¤ËÂФ·¤Æ¹Ô¤¦¤â¤Î¤¬¤¢¤ë¡£ =~ ±é»»»Ò¤òÍѤ¤¤ë¤È¡¢Ê̤Îʸ»úÎó¤ËÂФ·¤Æ¤½¤Î±é»»¤¬¹Ô¤ï¤ì¤ë¡£ ±¦¤Î°ú¿ô¤Ï¸¡º÷¥Ñ¥¿¡¼¥ó¡¦ÃÖ´¹¡¦ÊÑ´¹(translation) ¤Ç¤¢¤ê¡¢ º¸¤Î°ú¿ô¤Ï¥Ç¥Õ¥©¥ë¥È¤Î $_ ¤ÎÂå¤ï¤ê¤Ë ¸¡º÷¡¦ÃÖ´¹¡¦ÊÑ´¹¤ÎÂоݤȤʤëʸ»úÎó¤Ç¤¢¤ë¡£ÊÖ¤êÃͤϱ黻¤ÎÀ®ÈݤòÊÖ¤¹¡£ (±¦°ú¿ô¤¬¸¡º÷¥Ñ¥¿¡¼¥ó¡¦ÃÖ´¹¡¦ÊÑ´¹ ¤Ç¤Ï¤Ê¤¯¤Æ¤¢¤ë expression ¤Ç¤¢¤ë¾ì¹ç¤Ï¡¢ ¼Â¹Ô»þ¤Ë¸¡º÷¥Ñ¥¿¡¼¥ó¤È¤·¤Æ²ò¼á¤µ¤ì¤ë¡£ ¤½¤Î expression ¤¬É¾²Á¤µ¤ì¤ëÅ٤˥ѥ¿¡¼¥ó¤¬¥³¥ó¥Ñ¥¤¥ë¤µ¤ì¤ë¤Î¤Ç¡¢ ¤³¤ì¤Ï¥Ñ¥¿¡¼¥ó¤òÌÀ¼¨¤·¤¿¸¡º÷¤ËÈæ¤Ù¤ÆÈó¸úΨŪ¤Ç¤¢¤ë¡£) ¤³¤Î±é»»»Ò¤Ï -(ñ¹à¥Þ¥¤¥Ê¥¹±é»»»Ò)¡¢++¡¢-- ¤ò½ü¤¯ ¾¤Î±é»»¤è¤ê¤âÍ¥ÀèÅÙ¤¬¹â¤¤¡£
`!~'
ÊÖ¤êÃͤ¬ÈÝÄꤵ¤ì¤ë¤³¤È¤ò½ü¤¤¤Æ =~ ¤ÈƱ¤¸¤Ç¤¢¤ë¡£

·«¤êÊÖ¤·

`x'
·«¤êÊÖ¤·±é»»»Ò¡£º¸°ú¿ô¤ò±¦°ú¿ô²óʬ·«¤êÊÖ¤·¤¿Ê¸»úÎó¤òÊÖ¤¹¡£ ÇÛÎó¤Î¥³¥ó¥Æ¥­¥¹¥È¤Ç¤Ï¡¢º¸°ú¿ô¤¬³ç¸Ì¤ËÆþ¤Ã¤¿¥ê¥¹¥È¤Î¾ì¹ç¡¢¥ê¥¹¥È¤ò·«¤êÊÖ¤¹¡£
print '-' x 80;     # ¥À¥Ã¥·¥å¤ÎÎó¤ò½ÐÎϤ¹¤ë
print '-' x80;      # Àµ¤·¤¯¤Ê¤¤¡¢¤Ê¤¼¤Ê¤é x80 ¤Ï¼±Ê̻ҤÀ¤«¤é

print "\t" x ($tab/8), ' ' x ($tab%8);  # ¥¿¥Ö¤ËÊÑ´¹

@ones = (1) x 80;      # 80 ¸Ä 1 ¤¬Ê¤ó¤ÀÇÛÎó
@ones = (5) x @ones;   # Á´Í×ÁǤò 5 ¤Ë¤¹¤ë
`x='
·«¤êÊÖ¤· & ÂåÆþ±é»»»Ò¡£¥¹¥«¥é¡¼¤ËÂФ·¤Æ¤Î¤ßƯ¤¯¡£
`..'
ÈÏ°Ï»ØÄê±é»»»Ò¡£¥³¥ó¥Æ¥­¥¹¥È¤Ë¤è¤Ã¤Æ°Û¤Ê¤ëÆó¤Ä¤Î±é»»¤òɽ¤¹¡£ ÇÛÎó¤Î¥³¥ó¥Æ¥­¥¹¥È¤Ç¤Ï¡¢ º¸¤ÎÃͤ«¤é±¦¤ÎÃͤޤÇ(1 ¤º¤Ä)Áý¤ä¤·¤¿Ãͤò»ý¤ÄÇÛÎó¤òÊÖ¤¹¡£ ¤³¤ì¤Ï for (1..10) ¥ë¡¼¥×¤äÇÛÎó¤Î°ìÉô¤òÀÚ¤ê½Ð¤¹Áàºî¤Ë¤ÏÊØÍø¤Ç¤¢¤ë¡£ ¥¹¥«¥é¡¼¤Î¥³¥ó¥Æ¥­¥¹¥È¤Ç¤Ï .. ¤ÏÏÀÍýÃͤòÊÖ¤¹¡£ ±é»»»Ò¤Ï¥Õ¥ê¥Ã¥×¥Õ¥í¥Ã¥×¤Î¤è¤¦¤Ë 2 Ä̤ê¤ÎÃͤò¤È¤ê¡¢sed, awk, ¤½¤·¤Æ¤¤¤í¤¤¤í¤Ê¥¨¥Ç¥£¥¿¤Î¹ÔÈÏ°Ï(¥³¥ó¥Þ)±é»»»Ò¤ò¥¨¥ß¥å¥ì¡¼¥È¤¹¤ë¡£ .. ¤Ï¤½¤ì¤¾¤ì¤¬¼«Ê¬¤À¤±¤ÎÏÀÍý¾õÂÖ¤ò»ý¤Ã¤Æ¤¤¤Æ¡¢º¸°ú¿ô¤¬µ¶¤Ç¤¢¤ë¸Â¤ê¡¢ µ¶¤ÎÃͤò»ý¤Ä¡£¤¤¤Ã¤¿¤óº¸°ú¿ô¤¬¿¿¤Ë¤Ê¤ë¤È¡¢±¦°ú¿ô¤¬¿¿¤Ë¤Ê¤ë¤Þ¤Ç¿¿¤Ç¤¢¤ë¡£ ¤½¤Î¸å¡¢ÈÏ°Ï»ØÄê±é»»»Ò¤ÏºÆ¤Óµ¶¤Ë¤Ê¤ë¡£ (.. ¤Ï¼¡¤Ëɾ²Á¤µ¤ì¤ë¤Þ¤Ç¡¢µ¶¤Ë¤Ï¤Ê¤é¤Ê¤¤¡£ (º¸°ú¿ô¤Î¥Æ¥¹¥È¤Î·ë²Ì[ÌõÊä­])¿¿¤Ë¤Ê¤Ã¤¿É¾²Á¤Ë¤ª¤¤¤Æ¡¢ ±¦°ú¿ô¤ò¥Æ¥¹¥È¤·¤¿·ë²Ìµ¶¤Ë¤Ê¤ë¤³¤È¤¬¤¢¤ê¤¦¤ë(awk ¤Î¤è¤¦¤Ë)¤¬¡¢ ¤½¤ì¤Ç¤â°ìÅ٤Ͽ¿¤òÊÖ¤¹¡£ (sed ¤Î¤è¤¦¤Ë)¼¡¤Ëɾ²Á¤¹¤ë¤Þ¤Ç±¦°ú¿ô¤Î¥Æ¥¹¥È¤ò¤·¤¿¤¯¤Ê¤¤¾ì¹ç¤Ë¤Ï ¥É¥Ã¥È 2 ¤Ä¤ÎÂå¤ï¤ê¤Ë 3 ¤Ä(...)¤ò»È¤¨¤Ð¤è¤¤¡£) ±é»»»Ò¤¬µ¶¤Î´Ö¤Ï±¦°ú¿ô¤Ïɾ²Á¤µ¤ì¤º¡¢ ±é»»»Ò¤¬¿¿¤Î´Ö¤Ïº¸°ú¿ô¤Ïɾ²Á¤µ¤ì¤Ê¤¤¡£ Í¥ÀèÅÙ¤Ï || ¤ä && ¤è¤ê¤â¾¯¤·Ä㤤¡£ÊÖ¤êÃͤϵ¶¤Ê¤é¤Ð¥Ì¥ëʸ»úÎó¡¢ ¿¿¤Ê¤é¤Ð(1 ¤«¤é»Ï¤Þ¤ë)Ϣ³¤·¤¿¿ô»ú¤Ç¤¢¤ë¡£ ¤³¤Î¿ô»ú¤ÏÈÏ°Ï»ØÄê¤Ë½Ð²ñ¤¦Ëè¤Ë¥ê¥»¥Ã¥È¤µ¤ì¤ë¡£ ÈϰϤκǸå¤Î¿ô»ú¤Ë¤Ïʸ»úÎó `E0' ¤¬¤Ä¤±¤é¤ì¤ë¤Î¤Ç¡¢¿ôÃͤ˱ƶÁ¤Ï¤Ê¤¤¤¬¡¢ ºÇ¸å¤ÎÅÀ¤ò½ü¤­¤¿¤¤¾ì¹ç¤Ë¸¡º÷¤Î¤­¤Ã¤«¤±¤È¤Ê¤ë¡£ ¿ô»ú¤¬ 1 ¤è¤êÂ礭¤¯¤Ê¤ë¤Î¤òÂԤĤ³¤È¤ÇºÇ½é¤ÎÅÀ¤ò½ü¤¯¤³¤È¤¬¤Ç¤­¤ë¡£ ¥¹¥«¥é¡¼¤Î .. ¤Î°ú¿ô¤Î¤É¤Á¤é¤«¤ÎÃͤ¬ÀÅŪ¤Ê¾ì¹ç¤Ï¡¢ °ú¿ô¤Ï°ÅÌۤΤ¦¤Á¤ËÊÑ¿ô $. ¤ÈÈæ³Ó¤µ¤ì¤ë¡£ See section @hbox{@hbox to 1.6em{@tt@$.@hfil} : ºÇ¸å¤ËÆɤ߹þ¤ß¤ò¹Ô¤Ã¤¿¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤Î¸½ºß¤Î¹ÔÈÖ¹æ}. ¥¹¥«¥é¡¼±é»»»Ò¤È¤·¤Æ¤Ï :
if (101 .. 200) { print; }     # 200 ¹Ô½ÐÎϤ¹¤ë

next line if (1 .. /^$/); # ¥Ø¥Ã¥À¡¼¹Ô¤ò¥¹¥­¥Ã¥×

s/^/> / if (/^$/ .. eof());    # ËÜÂΤò°úÍѤ¹¤ë
ÇÛÎó±é»»»Ò¤È¤·¤Æ¤Ï:
for (101 .. 200) { print; }    # $_ ¤ò 100 ²ó½ÐÎϤ¹¤ë

@foo = @foo[$[ .. $#foo]; # ¹â²Á¤Ê¥Î¡¼¥ª¥Ú¥ì¡¼¥·¥ç¥ó
@foo = @foo[$#foo-4 .. $#foo]; # ºÇ¸å¤Î 5 Í×ÁǤò¼è¤ê½Ð¤¹

¥Õ¥¡¥¤¥ë¥Æ¥¹¥È±é»»»Ò

¤³¤Î±é»»»Ò¤Ï¥Õ¥¡¥¤¥ë̾¤«¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤ò°ú¿ô¤È¤·¤Æ°ì¤Ä¤È¤ê¡¢ ¤½¤Î¥Õ¥¡¥¤¥ë¤Ë¤Ä¤¤¤Æ²¿¤«¤¬¿¿¤«¤É¤¦¤«¤ò¸«¤ë¡£ °ú¿ô¤ò¾Êά¤¹¤ë¤È¡¢$_ ¤ò¥Æ¥¹¥È¤¹¤ë¡£ Îã³°¤Ï -t ¤Ç¡¢STDIN ¤ò¥Æ¥¹¥È¤¹¤ë¡£

¿¿¤Î¾ì¹ç¤Ï 1¡¢µ¶¤Î¾ì¹ç¤Ï " ¤«¡¢ ¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤·¤Ê¤¤¾ì¹ç¤Ï undefined value ¤òÊÖ¤¹¡£

Í¥ÀèÅÙ¤ÏÏÀÍý±é»»»Ò¡¢´Ø·¸±é»»»Ò¤è¤ê¤â¹â¤¤¤¬¡¢¿ô³Ø±é»»»Ò¤è¤ê¤ÏÄ㤤¡£

±é»»»Ò¤Î¼ïÎà¤Ï¡¢°Ê²¼¤ÎÄ̤ê¤Ç¤¢¤ë¡£

-r        ¥Õ¥¡¥¤¥ë¤ò¼Â¸ú uid/gid ¤ÇÆɤळ¤È¤¬¤Ç¤­¤ë¡£
-w        ¥Õ¥¡¥¤¥ë¤Ë¼Â¸ú uid/gid ¤Ç½ñ¤¯¤³¤È¤¬¤Ç¤­¤ë¡£
-x        ¥Õ¥¡¥¤¥ë¤ò¼Â¸ú uid/gid ¤Ç¼Â¹Ô¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
-o        ¥Õ¥¡¥¤¥ë¤Î½êÍ­¼Ô¤¬¼Â¸ú uid ¤Ç¤¢¤ë¡£

-R        ¥Õ¥¡¥¤¥ë¤ò¼Â uid/gid ¤ÇÆɤळ¤È¤¬¤Ç¤­¤ë¡£
-W        ¥Õ¥¡¥¤¥ë¤Ë¼Â uid/gid ¤Ç½ñ¤¯¤³¤È¤¬¤Ç¤­¤ë¡£
-X        ¥Õ¥¡¥¤¥ë¤ò¼Â uid/gid ¤Ç¼Â¹Ô¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
-O        ¥Õ¥¡¥¤¥ë¤Î½êÍ­¼Ô¤¬¼Â uid ¤Ç¤¢¤ë¡£

-e        ¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤¹¤ë¡£

-z        ¥Õ¥¡¥¤¥ë¥µ¥¤¥º¤¬ 0 ¤Ç¤¢¤ë¡£
-s        ¥Õ¥¡¥¤¥ë¥µ¥¤¥º¤¬ 0 ¤Ç¤Ê¤¤(¥Õ¥¡¥¤¥ë¥µ¥¤¥º¤òÊÖ¤¹)¡£

-f        ¥Õ¥¡¥¤¥ë¤Ï¥×¥ì¡¼¥ó¥Õ¥¡¥¤¥ë¤Ç¤¢¤ë¡£
-d        ¥Õ¥¡¥¤¥ë¤Ï¥Ç¥£¥ì¥¯¥È¥ê¤Ç¤¢¤ë¡£
-l        ¥Õ¥¡¥¤¥ë¤Ï¥·¥ó¥Ü¥ê¥Ã¥¯¥ê¥ó¥¯¤Ç¤¢¤ë¡£
-p        ¥Õ¥¡¥¤¥ë¤Ï̾Á°¤Ä¤­¥Ñ¥¤¥×(FIFO)¤Ç¤¢¤ë¡£
-S        ¥Õ¥¡¥¤¥ë¤Ï¥½¥±¥Ã¥È¤Ç¤¢¤ë¡£
-b        ¥Õ¥¡¥¤¥ë¤Ï¥Ö¥í¥Ã¥¯Æüì¥Õ¥¡¥¤¥ë¤Ç¤¢¤ë¡£
-c        ¥Õ¥¡¥¤¥ë¤Ï¥­¥ã¥é¥¯¥¿¡¼Æüì¥Õ¥¡¥¤¥ë¤Ç¤¢¤ë¡£

-u        ¥Õ¥¡¥¤¥ë¤Ë setuid ¥Ó¥Ã¥È¤¬¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤ë¡£
-g        ¥Õ¥¡¥¤¥ë¤Ë setgid ¥Ó¥Ã¥È¤¬¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤ë¡£
-k        ¥Õ¥¡¥¤¥ë¤Ë sticky ¥Ó¥Ã¥È¤¬¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤ë¡£

-t        ¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤¬ tty ¤Ë¥ª¡¼¥×¥ó¤µ¤ì¤Æ¤¤¤ë¡£

-T        ¥Õ¥¡¥¤¥ë¤Ï¥Æ¥­¥¹¥È¥Õ¥¡¥¤¥ë¤Ç¤¢¤ë¡£
-B        ¥Õ¥¡¥¤¥ë¤Ï¥Ð¥¤¥Ê¥ê¥Õ¥¡¥¤¥ë¤Ç¤¢¤ë¡£(-T ¤ÎµÕ)
-M        ¥¹¥¯¥ê¥×¥È¤Î¼Â¹Ô¤ò³«»Ï¤·¤¿»þÅÀ¤Ç¤Î¥Õ¥¡¥¤¥ë¤Î¸Å¤µ(age)(ñ°Ì¤ÏÆü)
-A        ¥¹¥¯¥ê¥×¥È¤Î¼Â¹Ô¤ò³«»Ï¤·¤¿»þÅÀ¤Ç¤Î¥Õ¥¡¥¤¥ë¤Î¥¢¥¯¥»¥¹»þ´Ö
-C        ¥¹¥¯¥ê¥×¥È¤Î¼Â¹Ô¤ò³«»Ï¤·¤¿»þÅÀ¤Ç¤Î¥Õ¥¡¥¤¥ë¤Î inode Êѹ¹»þ´Ö

±é»»»Ò -r,-R,-w,-W,-x,-X ¤ÎȽÃǤϡ¢ ¥Õ¥¡¥¤¥ë¤Î¥â¡¼¥É¤È¥æ¡¼¥¶¤Î uid¡¢gid ¤Î¤ß¤Ë¤è¤ë¡£ ¼ÂºÝ¤ËÆɤß/½ñ¤­/¼Â¹Ô¤Ç¤­¤Ê¤¤¾ì¹ç¤¬¤¢¤ë¤«¤â¤·¤ì¤Ê¤¤¡£

¤Þ¤¿¡¢¥¹¡¼¥Ñ¡¼¥æ¡¼¥¶¤Î¾ì¹ç¤Ï¡¢ -r,-R,-w,-W ¤Ï¾ï¤Ë 1 ¤òÊÖ¤·¡¢ -x,-X ¤Ë¤Ä¤¤¤Æ¤Ï ¥Õ¥¡¥¤¥ë¥â¡¼¥É¤Ë¤¤¤º¤ì¤«¤Î¼Â¹Ôµö²Ä¤¬¤Ä¤¤¤Æ¤¤¤ì¤Ð 1 ¤òÊÖ¤¹¡£ ¤³¤Î¤¿¤á¡¢¥¹¡¼¥Ñ¡¼¥æ¡¼¥¶¤¬¼Â¹Ô¤¹¤ë¥¹¥¯¥ê¥×¥È¤Ë¤ª¤¤¤Æ ¼ÂºÝ¤Î¥Õ¥¡¥¤¥ë¥â¡¼¥É¤òÆÀ¤ë¤¿¤á¤Ë¤Ï¡¢stat() ¤ò¹Ô¤¦¤«¡¢ °ì»þŪ¤Ë uid ¤ò¾¤Î¤â¤Î¤Ë¥»¥Ã¥È¤¹¤ëɬÍפ¬¤¢¤ë¡£

while (<>) {
     chop;
     next unless -f $_;  # Æüì¥Õ¥¡¥¤¥ë¤Ï̵»ë¤¹¤ë
     ...
}

(Ãí°Õ)

¥Õ¥¡¥¤¥ë¥Æ¥¹¥È¤Ë¤ª¤¤¤Æ `_'(²¼Àþ)¤À¤±¤«¤é¤Ê¤ë Æüì¤Ê¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤ò»ØÄꤹ¤ë¤È¡¢ Á°²ó¤Î¥Õ¥¡¥¤¥ë¥Æ¥¹¥È(¤Þ¤¿¤Ï stat() )¤Ç¤Î stat ¹½Â¤ÂΤ¬ÍѤ¤¤é¤ì¡¢ ¥·¥¹¥Æ¥à¥³¡¼¥ë¤ò¹Ô¤ï¤Ê¤¤¡£ (-t ¤Ï½ü¤¯¡£¤Þ¤¿¡¢lstat() ¤ä -l ¤Ï ¼ÂºÝ¤Î¥Õ¥¡¥¤¥ë¤Ç¤Ï¤Ê¤¯¥·¥ó¥Ü¥ê¥Ã¥¯¥ê¥ó¥¯¤Î¾ðÊó¤ò stat ¹½Â¤ÂΤ˻Ĥ¹¤³¤È¤ò ³Ð¤¨¤Æ¤ª¤¯É¬Íפ¬¤¢¤ë¡£)

print "Can do.\n" if -r $a || -w _ || -x _;

stat($filename);
print "Readable\n" if -r _;
print "Writable\n" if -w _;
print "Executable\n" if -x _;
print "Setuid\n" if -u _;
print "Setgid\n" if -g _;
print "Sticky\n" if -k _;
print "Text\n" if -T _;
print "Binary\n" if -B _;

±é»»»Ò¤½¤Î¾

perl ¤Ë¤Ê¤¯¤Æ C ¤Ë¤À¤±¤¢¤ë±é»»»Ò¤Ï°Ê²¼¤ÎÄ̤ꡣ

`ñ¹à±é»»»Ò &'
"¡Á¤Î¥¢¥É¥ì¥¹"±é»»»Ò¡£
`ñ¹à±é»»»Ò *'
"¥¢¥É¥ì¥¹¤òÄ̤·¤Æ¤Î»²¾È"±é»»»Ò¡£
`(·¿)'
·¿ÊÑ´¹±é»»»Ò¡£

perl ¤Ï C ¤ÈƱ¤¸¤¯¡¢±é»»»Ò¤ËÂФ¹¤ë°ú¿ô¤¬Á´¤ÆÀÅŪ¤Ç¤¢¤ê¡¢ ÉûºîÍѤâ¤Ê¤¤¤ÈȽÃǤ·¤¿»þ¤Ï expression ¤Îɾ²Á¤ò¥³¥ó¥Ñ¥¤¥ë»þ¤Ë¹Ô¤¦ (Æäˡ¢¥³¥ó¥Ñ¥¤¥ë»þ¤ËÊÑ¿ôÃÖ´¹¤ò¹Ô¤ï¤Ê¤¤Ê¸»úÎó´Ö¤Î·ë¹ç¤òȯ¸«¤·¤¿¾ì¹ç)¡£ ¥Ð¥Ã¥¯¥¹¥é¥Ã¥·¥å¤Î²ò¼á¤â¥³¥ó¥Ñ¥¤¥ë»þ¤Ë¹Ô¤ï¤ì¤ë¡£

'Now is the time for all' . "\n" .
'good men to come to.'

¤³¤ì¤Ï°ì¤Ä¤Îʸ»úÎó¤Ë¤Ê¤Ã¤Æ¤·¤Þ¤¦¡£

++ ±é»»»Ò¤Ë¤Ï¤Á¤ç¤Ã¤È¤·¤¿ºÙ¹©¤ò¤·¤Æ¤¤¤ë¡£ ¿ô»ú¤ä¡¢¿ôÃͤΥ³¥ó¥Æ¥­¥¹¥È¤Ç»È¤Ã¤¿ÊÑ¿ô¤ò¥¤¥ó¥¯¥ê¥á¥ó¥È¤¹¤ë¤È¡¢ Ä̾ï¤Î¥¤¥ó¥¯¥ê¥á¥ó¥È¤ò¹Ô¤¦¡£ ¤·¤«¤·¡¢¥»¥Ã¥È¤·¤Æ¤«¤éʸ»úÎó¤Î¥³¥ó¥Æ¥­¥¹¥È¤Ç¤·¤«»È¤Ã¤Æ¤ª¤é¤º¡¢ ¥Ì¥ë¤Ç¤Ê¤¤Ãͤò»ý¤Ã¤Æ¤¤¤Æ¡¢ ¥Ñ¥¿¡¼¥ó /^[a-zA-Z]*[0-9]*$/ ¤Ë¥Þ¥Ã¥Á¤¹¤ë¤è¤¦¤ÊÊÑ¿ô¤Î¾ì¹ç¡¢ ʸ»úÎó¤È¤·¤Æ¤Î¥¤¥ó¥¯¥ê¥á¥ó¥È¤òʸ»úÎó¤ÎÈϰϤϤ½¤Î¤Þ¤Þ¡¢ ¥­¥ã¥ê¡¼ÉÕ¤­¤Ç¹Ô¤¦¡£

print ++($foo = '99');   # prints '100'
print ++($foo = 'a0');   # prints 'a1'
print ++($foo = 'Az');   # prints 'Ba'
print ++($foo = 'zz');   # prints 'aaa'

-- ±é»»»Ò¤Ë¤Ï¤³¤Î¤è¤¦¤ÊºÙ¹©¤Ï¤Ê¤¤¡£

(ÇÛÎó¤Î¥³¥ó¥Æ¥­¥¹¥È¤Ë¤ª¤±¤ë)Èϰϱ黻»Ò¤Ï¡¢ ºÇ¾®ÃͤȺÇÂçÃͤ¬Ê¸»úÎó¤Î¾ì¹ç¤Ï ++ ±é»»»Ò¤ÎºÙ¹©¤òÍøÍѤ·¤Æ¤¤¤ë¡£ ¥¢¥ë¥Õ¥¡¥Ù¥Ã¥Èʸ»ú¤ÎÁ´¤Æ¤òÆÀ¤ë¤¿¤á¤Ë¤Ï¼¡¤Î¤è¤¦¤Ëµ­½Ò¤Ç¤­¤ë¡£

@alphabet = ('A' .. 'Z');

¤Þ¤¿¡¢16 ¿Ê¤ÎÃͤòÆÀ¤ë¤¿¤á¤Ë¤Ï¡¢

$hexdigit = (0 .. 9, 'a' .. 'f')[$num & 15];

¤½¤·¤Æ¡¢ºÇ½é¤Ë 0 ¤¬¤Ä¤¤¤¿ÆüÉÕ¤òÆÀ¤ë¤¿¤á¤Ë¤Ï¡¢

@z2 = ('01' .. '31');  print @z2[$mday];

¤È½ñ¤±¤ë¡£ (»ØÄꤷ¤¿ºÇ½ªÃͤ¬ ++ ¤ÎºÙ¹©¤¬½èÍý¤¹¤ë½çÈ֤ˤʤäƤ¤¤Ê¤¤¾ì¹ç¤Ï¡¢ ¼¡¤ÎÃͤ¬»ØÄꤷ¤¿ºÇ½ªÃͤè¤êŤ¯¤Ê¤ë¤Þ¤Ç·«¤êÊÖ¤µ¤ì¤ë¡£)

|| ¤ä && ¤Ï C ¤Î¤½¤ì¤È¤Ï°Û¤Ê¤ê¡¢ 0 ¤ä 1 ¤òÊÖ¤¹Âå¤ï¤ê¤ËºÇ¸å¤Ëɾ²Á¤·¤¿ÃͤòÊÖ¤¹¡£¤³¤Î¤¿¤á¡¢ ¥Û¡¼¥à¥Ç¥£¥ì¥¯¥È¥ê¤òõ¤¹¤¿¤á¤Î°Ü¿¢À­¤Î¹â¤¤ÊýË¡¤Ï¼¡¤Î¤è¤¦¤Ë¤Ê¤ë¡£

$home = $ENV{'HOME'} || $ENV{'LOGDIR'} ||
        (getpwuid($<))[7] || die "You're homeless!\n";

Á°¾Ï¤Þ¤Ç¤Ë½Ò¤Ù¤¿Ê¸»ú¤äÊÑ¿ô¤ÈƱ¤¸¤¯¡¢ ¼¡¾Ï°Ê¹ß¤Ç½Ò¤Ù¤ë±é»»»Ò¤Ï expression Ãæ¤Î"¸ì"¤È¤·¤Æµ¡Ç½¤¹¤ë¡£ ±é»»»Ò¤ÎÃæ¤Ë¤Ï¥ê¥¹¥È¤ò°ú¿ô¤Ë¼è¤ë¤â¤Î¤¬¤¢¤ë¡£ ¤³¤Î¥ê¥¹¥È¤Ï¥¹¥«¥é¡¼¤Î°ú¿ô¤äÇÛÎóÃͤ¬Ç¤°Õ¤Ë·ë¹ç¤µ¤ì¤¿¤â¤Î¤Ç¤¢¤ë¡£ ÇÛÎóÃͤϡ¢ ¥ê¥¹¥È¤Î¤½¤Î°ÌÃ֤˸ġ¹¤ÎÍ×ÁǤò½ñ¤¤¤Æ 1 ¼¡¸µ¤ÎÇÛÎóÃͤò¤¿¤¯¤µ¤óÀ¸À®¤·¤¿¤è¤¦¤Ê·Á¤Ç ¥ê¥¹¥È¤ËµÛ¼ý¤µ¤ì¤ë¡£

¥ê¥¹¥È¤ÎÍ×ÁǤϥ³¥ó¥Þ¤Ç¶èÀÚ¤ëɬÍפ¬¤¢¤ë¡£

±é»»»Ò¤ò¥ê¥¹¥È¤¹¤ë¤È¡¢°ú¿ô¤ÎÁ°¸å¤Ë³ç¸Ì¤¬¤¢¤ë¾ì¹ç¤Ê¤¤¾ì¹ç¶¦¤Ë¡¢ ¤½¤Î±é»»»Ò¤òñ¹à±é»»»Ò¤Þ¤¿¤Ï´Ø¿ô¸Æ¤Ó½Ð¤·¤È¤·¤Æ»È¤¦¤³¤È¤¬¤Ç¤­¤ë¡£

´Ø¿ô¸Æ¤Ó½Ð¤·¤È¤·¤Æ»È¤¦¾ì¹ç¤Ï¡¢ Ʊ¤¸¹Ô¤Î¼¡¤Î¥È¡¼¥¯¥ó¤Ïº¸³ç¸Ì¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤(´Ö¤Ë¥¹¥Ú¡¼¥¹¤¬¤¢¤Ã¤Æ¤â¤è¤¤)¡£ ¤³¤Î¤è¤¦¤Ê´Ø¿ô¤Ï´üÂÔÄ̤ê¤ÎºÇ¤â¹â¤¤Í¥ÀèÅÙ¤ò»ý¤Ä¡£

º¸³ç¸Ì°Ê³°¤Î¥È¡¼¥¯¥ó¤¬Â³¤¯¾ì¹ç¤Ï¡¢Ã±¹à±é»»»Ò¤È¤·¤Æ°·¤ï¤ì¡¢ ¥ê¥¹¥È¤ò°ú¿ô¤Ë¼è¤ë±é»»»Ò¤«¤½¤¦¤Ç¤Ê¤¤¤«¤Î¤ß¤Ë¤è¤êÍ¥ÀèÅÙ¤¬·è¤Þ¤ë¡£ ¥ê¥¹¥È¤ò°ú¿ô¤Ë¼è¤ë¾ì¹ç¤ÏºÇ¤âÄ㤤ͥÀèÅ٤ˤʤ롣 ¾¤ÎÁ´¤Æ¤Îñ¹à±é»»»Ò¤Ï´Ø·¸±é»»»Ò¤è¤ê¤Ï¹â¤¤¤¬¿ôÃͱ黻»Ò¤è¤ê¤ÏÄ㤤ͥÀèÅ٤ˤʤ롣 Í¥ÀèÅ٤ξϤò»²¾È¤Î¤³¤È¡£See section Í¥ÀèÅÙ.

¥¹¥«¥é¡¼¡¢ÇÛÎó¤Îξ¥³¥ó¥Æ¥­¥¹¥È¤Ç»ÈÍѤǤ­¤ë±é»»»Ò¤Ï¡¢°ìÈÌŪ¤Ë¥¹¥«¥é¡¼¥³ ¥ó¥Æ¥­¥¹¥È¤Ç¤Ï undefined value¡¢ÇÛÎó¤Î¥³¥ó¥Æ¥­¥¹¥È¤Ç¤Ï¥Ì¥ë¥ê¥¹¥È¤òÊÖ¤¹¤³ ¤È¤ÇÉÔÀ®¸ù¤ò¼¨¤¹¡£¤·¤«¤·¡¢¥ê¥¹¥È¤ò¥¹¥«¥é¡¼¤ØÊÑ´¹¤¹¤ë°ìÈÌŪ¤Ê¥ë¡¼¥ë ¤Ï¤Ê¤¤¤È¤¤¤¦¤³¤È¤ò³Ð¤¨¤Æ¤ª¤¤¤ÆÍߤ·¤¤¡£¤½¤ì¤¾¤ì¤Î±é»»»Ò¤Ï¡¢¤É¤Î¤è¤¦¤Ê¥¹ ¥«¥é¡¼¤òÊÖ¤»¤ÐºÇ¤âŬÀÚ¤«¤ò·èÄꤹ¤ë¡£ÇÛÎó¤Î¥³¥ó¥Æ¥­¥¹¥È¤ÇÊÖ¤·¤¿¤Ç¤¢¤í¤¦¥ê ¥¹¥È¤ÎŤµ¤òÊÖ¤¹±é»»»Ò¡¢¥ê¥¹¥È¤ÎºÇ½é¤ÎÍ×ÁǤòÊÖ¤¹±é»»»Ò¡¢¥ê¥¹¥È¤ÎºÇ¸å¤ÎÍ× ÁǤòÊÖ¤¹±é»»»Ò¡¢À®¸ù¤·¤¿Áàºî¤Î¿ô¤òÊÖ¤¹±é»»»Ò¡¢¤Ê¤É¤¬¤¢¤ë¡£Áí¤¸¤Æ¡¢¤³¤ì¤é ¤Î±é»»»Ò¤Ï¤¢¤Ê¤¿¤¬µá¤á¤ë¤³¤È¤ò¤·¤Æ¤¯¤ì¤ë¡£°ì´ÓÀ­¤òµá¤á¤Ê¤¤¤«¤®¤ê¡£

¥Õ¥í¡¼À©¸æ

do

`do BLOCK'
BLOCK ¤Ç»Ø¼¨¤µ¤ì¤ë¥³¥Þ¥ó¥É·²¤ÎºÇ¸å¤Î¥³¥Þ¥ó¥É¤ÎÃͤ¬Ê֤롣 ¥ë¡¼¥×½¤¾þ»Ò¤Ç½¤¾þ¤µ¤ì¤¿¾ì¹ç¤Ï¡¢ ¥ë¡¼¥×¾ò·ï¤ò¥Æ¥¹¥È¤¹¤ëÁ°¤Ë°ì²ó¼Â¹Ô¤µ¤ì¤ë¡£ (¾¤Îʸ¤Ç¤Ï¥ë¡¼¥×½¤¾þ»Ò¤Ï¾ò·ï¥Æ¥¹¥È¤òºÇ½é¤Ë¹Ô¤¦¡£)
`do SUBROUTINE (LIST)'
sub ¤ÇÀë¸À¤µ¤ì¤¿ SUBROUTINE ¤ò¼Â¹Ô¤·¡¢ SUBROUTINE ¤Çɾ²Á¤µ¤ì¤¿ºÇ¸å¤Î expression ¤ÎÃͤòÊÖ¤¹¡£ ¤½¤Î̾Á°¤Î¥µ¥Ö¥ë¡¼¥Á¥ó¤¬¤Ê¤¤¾ì¹ç¤Ï¡¢Ã×̿Ū¥¨¥é¡¼¤È¤Ê¤ë (¥µ¥Ö¥ë¡¼¥Á¥ó¤¬Â¸ºß¤¹¤ë¤«¤É¤¦¤«ÃΤë¤Ë¤Ï¡¢ defined ±é»»»Ò¤ò»ÈÍѤ¹¤ì¤ÐÎɤ¤¡£)¡£ LIST ¤Î°ìÉô¤È¤·¤ÆÇÛÎó¤òÅϤ¹¾ì¹ç¡¢ ³ÆÇÛÎó¤ÎÁ°¤ËÇÛÎó¤ÎŤµ¤òÅϤ·¤Æ¤â¤¤¤¤¤À¤í¤¦¡£ (¥µ¥Ö¥ë¡¼¥Á¥ó¤Î¾Ï¤ò»²¾È¡£See section ¥µ¥Ö¥ë¡¼¥Á¥ó.) `do EXPR' ¤È¤Îº®Íð¤òËɤ°¤¿¤á¡¢³ç¸Ì¤ÏɬÍפǤ¢¤ë¡£ SUBROUTINE ¤Ï°ì¥¹¥«¥é¡¼ÊÑ¿ô¤Ç¤¢¤Ã¤Æ¤â¤è¤¤¡£ ¤³¤Î¾ì¹ç¼Â¹Ô¤¹¤Ù¤­¥µ¥Ö¥ë¡¼¥Á¥ó¤Î̾Á°¤Ï¤½¤ÎÊÑ¿ô¤«¤é¼è¤ê½Ð¤µ¤ì¤ë¡£ Ê̤νñ¤­Êý¤È¤·¤Æ(¤½¤·¤Æ˾¤Þ¤·¤¤½ñ¤­Êý¤È¤·¤Æ)¡¢ ̾Á°¤ÎÁ°¤Ë & ¤ò¤Ä¤±¤Æ¥µ¥Ö¥ë¡¼¥Á¥ó¤ò¥³¡¼¥ë¤·¤Æ¤âÎɤ¤¡£ Îã: &foo(@args) °ú¿ô¤òÅϤµ¤Ê¤¤¤Î¤Ç¤¢¤ì¤Ð¡¢³ç¸Ì¤ò»È¤¦É¬ÍפϤʤ¤¡£ ³ç¸Ì¤ò¾Êά¤·¤¿¾ì¹ç¡¢¥µ¥Ö¥ë¡¼¥Á¥ó¤Ë¤ÏÇÛÎó @_ ¤ÏÅϤµ¤ì¤Ê¤¤¡£ & ·Á¼°¤Ï defined ¤ª¤è¤Ó undef ¤Ë ¥µ¥Ö¥ë¡¼¥Á¥ó¤ò»Ø¼¨¤¹¤ë¤Î¤Ë¤â»È¤¨¤ë¡£
if (defined &$var) { &$var($parm); undef &$var; }
`do EXPR'
EXPR ¤ò¥Õ¥¡¥¤¥ë̾¤È¤·¤Æ¡¢ ¤½¤Î¥Õ¥¡¥¤¥ë¤ÎÆâÍƤò perl ¥¹¥¯¥ê¥×¥È¤È¤·¤Æ¼Â¹Ô¤¹¤ë¡£ ¤½¤Î¼ç¤¿¤ë»ÈÍÑË¡¤Ï¡¢ perl ¥µ¥Ö¥ë¡¼¥Á¥ó¥é¥¤¥Ö¥é¥ê¤«¤é¥µ¥Ö¥ë¡¼¥Á¥ó¤ò¥¤¥ó¥¯¥ë¡¼¥É¤¹¤ë¤³¤È¤Ç¤¢¤ë¡£
do 'stat.pl';
¤Ï¡¢
eval `cat stat.pl`;
¤ÈÁ´¤¯Æ±¤¸¤Ç¤¢¤ë¡£ (¤è¤ê¸úΨŪ¤Ç¡¢¤è¤ê´Ê·é¤Ç¡¢¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤Ç¤Î¥Õ¥¡¥¤¥ë̾¤ÏÀµ¤·¤¯¡¢ ¥«¥ì¥ó¥È¥Ç¥£¥ì¥¯¥È¥ê¤Ë¤Ê¤±¤ì¤Ð -I ¤Ç»ØÄꤵ¤ì¤¿¥é¥¤¥Ö¥é¥ê¤ò Á´¤Æ¸¡º÷¤¹¤ëÅÀ¤¬°Û¤Ê¤ë¡£See section {@tt@INC} : perl ¥¹¥¯¥ê¥×¥È¤òõ¤¹¾ì½ê¤Î¥ê¥¹¥È.) ¤·¤«¤·¡¢¥³¡¼¥ë¤¹¤ëËè¤Ë parse ¤·Ä¾¤¹¤Î¤ÏƱ¤¸¤Ê¤Î¤Ç¡¢ ¥ë¡¼¥×¤ÎÃæ¤Ç»ÈÍѤ¹¤ëºÝ¤Ë¤Ï -P ¥ª¥×¥·¥ç¥ó ¤ª¤è¤Ó #include ¤ò»È¤Ã¤¿Êý¤¬¤è¤¤(¼ã´³Î©¤Á¾å¤²»þ´Ö¤¬Áý¤¨¤ë¤¬)¡£ #include ¤ÎÌäÂêÅÀ¤Ï¡¢cpp ¤Ï # ¤¬¥³¥á¥ó¥È¤Ç¤¢¤ë¤³¤È¤ò ¤ï¤«¤Ã¤Æ¤¯¤ì¤Ê¤¤¤³¤È¤Ç¤¢¤ë -- ¥³¥á¥ó¥È¤À¤±¤«¤é¤Ê¤ë¹Ô¤Ë¤Ï `;#' ¤ò »È¤¦¤³¤È¤Ë¤Ê¤ë¡£ Ãí°Õ:
¼¡¤Î 2 ʸ¤ÏƱÅù¤Ç¤Ï¤Ê¤¤¡£
do $foo;	# ¥Õ¥¡¥¤¥ë¤òɾ²Á¤¹¤ë
do $foo();	# ¥µ¥Ö¥ë¡¼¥Á¥ó¤ò¸Æ¤Ö
¥é¥¤¥Ö¥é¥ê¥ë¡¼¥Á¥ó¤ò¥¤¥ó¥¯¥ë¡¼¥É¤¹¤ë¤Ë¤Ï require ¥ª¥Ú¥ì¡¼¥¿¤¬¤è¤¤¡£ See section require.

goto

`goto LABEL'
LABEL ¤È¤¤¤¦¥é¥Ù¥ëÀë¸À¤ò¸¡º÷¤·¡¢¤½¤³¤«¤é¼Â¹Ô¤òºÆ³«¤¹¤ë¡£ ¸½ºß¤Ï do {} ¹½Â¤¤ÎÃæ¤ò½ü¤¯ ¥×¥í¥°¥é¥à¤ÎËÜÂÎÆâ¤Î¥é¥Ù¥ë¤Ë¤·¤« goto ¤Ç¤­¤Ê¤¤¡£ goto ¤Ï¤¢¤Þ¤ê¸úΨŪ¤Ë¤Ï¥¤¥ó¥×¥ê¥á¥ó¥È¤µ¤ì¤Æ¤ª¤é¤º¡¢ sed-to-perl ÊÑ´¹¤òÍưפˤ·¤Æ¤¤¤ë¤À¤±¤Ç¤¢¤ë¡£»ä¤¬¤¤¤Ä¡¢ sed ¥¹¥¯¥ê¥×¥È¤Î¥µ¥Ý¡¼¥È¤Ï»Ä¤·¤¿¤Þ¤Þ¤³¤Î¥»¥Þ¥ó¥Æ¥£¥¯¥¹¤òÊѹ¹¤¹¤ë¤«¤ï¤«¤é¤Ê¤¤¡£ »È¤¤¤¿¤±¤ì¤Ð¼«¤é¤ÎÀÕǤ¤Ç»È¤¦¤³¤È¡£Á´¤¯»È¤ï¤Ê¤¤¤Î¤¬°ìÈÖÎɤ¤¡£

last

`last LABEL'
`last'
last ¥³¥Þ¥ó¥É¤Ï C ¤Ç¤Î break(¥ë¡¼¥×Ãæ¤Ç»ÈÍѤµ¤ì¤ë) ¤È»÷¤Æ¤¤¤ë¡£¸½ºß¼Â¹ÔÃæ¤Î¥ë¡¼¥×¤«¤éľ¤Á¤ËÈ´¤±½Ð¤¹¡£ LABEL ¤ò¾Êά¤¹¤ë¤È¡¢ºÇ¤â±ü¤Î¥ë¡¼¥×¤ò¹½À®¤¹¤ë°Ï¤ß¤ÎºÇ¸å¤Ë¤È¤Ö¡£ continue ¤¬¤â¤·¤¢¤Ã¤Æ¤â¡¢¼Â¹Ô¤µ¤ì¤Ê¤¤¡£
line: while (<STDIN>) {
     last line if /^$/;  # ¥Ø¥Ã¥À¡¼¤¬½ª¤ï¤Ã¤¿¤éÈ´¤±¤ë
     ...
}

next

`next LABEL'
`next'
next ¥³¥Þ¥ó¥É¤Ï C ¤Ë¤ª¤±¤ë continue ¤Ë»÷¤Æ¤¤¤Æ¡¢ ¥ë¡¼¥×¤Î¼¡¤Î·«¤êÊÖ¤·¤ò¹Ô¤¦¡£
line: while (<STDIN>) {
     next line if /^#/;  # ¥³¥á¥ó¥È¤Ï¼Î¤Æ¤ë
     ...
}
Ãí°Õ:
¤â¤· continue ¥Ö¥í¥Ã¥¯¤¬¾åÎã¤Ë¤¢¤ì¤Ð¡¢ ̵»ë¤µ¤ì¤ë¹Ô¤Ç¤¢¤Ã¤Æ¤â¼Â¹Ô¤µ¤ì¤ë¡£LABEL ¤ò¾Êά¤·¤¿¾ì¹ç¡¢ next ¤Ï³ç¸Ì¤Ç°Ï¤Þ¤ì¤¿¥ë¡¼¥×¤ÎºÇ¸å¤Ë¤È¤Ö¡£

redo

`redo LABEL'
`redo'
redo ¥³¥Þ¥ó¥É¤Ï¾ò·ï¤òɾ²Á¤¹¤ë¤³¤È¤Ê¤¯¥ë¡¼¥×¥Ö¥í¥Ã¥¯¤òºÆ¤Ó¼Â¹Ô¤¹¤ë¡£ continue ¥Ö¥í¥Ã¥¯¤¬¤â¤·¤¢¤Ã¤Æ¤â¡¢¼Â¹Ô¤µ¤ì¤Ê¤¤¡£ LABEL ¤ò¾Êά¤¹¤ë¤È¡¢ºÇ¤âÆ⦤ÎÊĤ¸¤¿¥ë¡¼¥×¤òÍѤ¤¤ë¡£ ¤³¤Î¥³¥Þ¥ó¥É¤ÏÄ̾ ÆþÎϤµ¤ì¤¿ÆâÍƤˤĤ¤¤Æ¼«Ê¬¼«¿È¤Ë±³¤ò¤Ä¤¯¤è¤¦¤Ê¥×¥í¥°¥é¥à¤ÇÍѤ¤¤ë¡£
# ñ½ã¤Ê Pascal ¥³¥á¥ó¥È½üµî¥×¥í¥°¥é¥à
# (Ãí°Õ: ʸ»úÎóÃæ¤Ë {} ¤¬¤Ê¤¤¤È²¾Äꤷ¤Æ¤¤¤ë)
line: while (<STDIN>) {
     while (s|({.*}.*){.*}|$1 |) {}
     s|{.*}| |;
     if (s|{.*| |) {
        $front = $_;
        while (<STDIN>) {
             if (/}/) {     # ¥³¥á¥ó¥È¤Î½ª¤ï¤ê?
               s|^|$front{|;
                redo line;
             }
        }
     }
     print;
}

return

`return LIST'
»ØÄꤷ¤¿Ãͤǥµ¥Ö¥ë¡¼¥Á¥ó¤«¤éÊ֤롣 Ãí°Õ:
¥µ¥Ö¥ë¡¼¥Á¥ó¤«¤é¤Ï¡¢ºÇ¸å¤Ëɾ²Á¤·¤¿ expression ¤ÎÃͤǼ«Æ°Åª¤ËÊ֤롣 ¤½¤ì¤¬¤ª´«¤á¤Ç¤¢¤ë -- return ¤òÌÀ¼¨¤¹¤ë¤È¡¢¼ã´³ÃÙ¤¯¤Ê¤ë¡£

¿ô³Ø´Ø¿ô

atan2

`atan2(X,Y)'
Y / X ¤Î arctangent ¤ò -¦Ð ¤«¤é ¦Ð ¤Þ¤Ç¤ÎÈϰϤÇÊÖ¤¹¡£

cos

`cos(EXPR)'
`cos EXPR'
EXPR ¤Ï¥é¥¸¥¢¥ó¡£¾Êά¤¹¤ë¤È $_ ¤ò»È¤¦¡£

sin

`sin(EXPR)'
`sin EXPR'
EXPR(¥é¥¸¥¢¥ó) ¤Î¥µ¥¤¥ó¤òÊÖ¤¹¡£ EXPR ¤ò¾Êά¤¹¤ë¤È¡¢$_ ¤Î¥µ¥¤¥ó¤òÊÖ¤¹¡£

exp

`exp(EXPR)'
`exp EXPR'
e ¤Î EXPR ¾è¤òÊÖ¤¹¡£ EXPR ¤ò¾Êά¤¹¤ë¤È¡¢exp($_) ¤òÊÖ¤¹¡£

sqrt

`sqrt(EXPR)'
`sqrt EXPR'
EXPR ¤Î¥ë¡¼¥È(2 ¾èº¬)¤òÊÖ¤¹¡£ EXPR ¤ò¾Êά¤¹¤ë¤È¡¢$_ ¤Î¥ë¡¼¥È¤òÊÖ¤¹¡£

int

`int(EXPR)'
`int EXPR'
EXPR ¤òÀ°¿ô¤ËÊÑ´¹¤·¤¿ÃͤòÊÖ¤¹¡£ EXPR ¤ò¾Êά¤¹¤ë¤È¡¢$_ ¤ò»ÈÍѤ¹¤ë¡£

log

`log(EXPR)'
`log EXPR'
EXPR ¤Î(´ð e ¤Î)log ¤òÊÖ¤¹¡£ EXPR ¤ò¾Êά¤¹¤ë¤È¡¢$_ ¤Î log ¤òÊÖ¤¹¡£

rand

`rand(EXPR)'
`rand EXPR'
`rand'
0 ¤«¤é EXPR ¤Î´Ö¤Î¥é¥ó¥À¥à¤Ê¾®¿ôÅÀ¤Î¿ôÃͤòÊÖ¤¹(EXPR ¤ÏÀµ¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤)¡£ EXPR ¤ò¾Êά¤¹¤ë¤È¡¢0 ¤È 1 ¤Î´Ö¤ÎÃͤòÊÖ¤¹¡£srand() ¤â»²¾È¡£

srand

`srand(EXPR)'
`srand EXPR'
rand ±é»»»Ò¤ÇÍѤ¤¤ëÍð¿ô¤Î seed ¤ò¥»¥Ã¥È¤¹¤ë¡£ EXPR ¤ò¾Êά¤¹¤ë¤È¡¢srand(time) ¤ò¼Â¹Ô¤¹¤ë¡£

time

`time'
1970 ǯ 1 ·î 1 Æü 0 »þ 0 ʬ 0 ÉÃ(UTC)¤«¤é¤ÎÉÿô¤òÊÖ¤¹¡£ gmtime() ¤ä localtime() ¤Ë»ØÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤ë¡£ gmtime ¤ª¤è¤Ó localtime ¤Ë¤Ä¤¤¤Æ¤Ï See section ÊÑ´¹´Ø¿ô.

ÊÑ´¹´Ø¿ô

gmtime

`gmtime(EXPR)'
`gmtime EXPR'
time ´Ø¿ô¤¬ÊÖ¤¹»þ´Ö¤ò Greenwich timezone ¤È¤·¤Æ Í×ÁÇ¿ô 9 ¤ÎÇÛÎó¤ËÊÑ´¹¤¹¤ë¡£Åµ·¿Åª¤Ë°Ê²¼¤Î¤è¤¦¤Ë»ÈÍѤµ¤ì¤ë¡£
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
        gmtime(time);
ÇÛÎó¤ÎÁ´Í×ÁǤϿôÃͤǤ¢¤ê¡¢ struct tm ¤«¤éľÀÜÆÀ¤é¤ì¤¿¤â¤Î¤Ç¤¢¤ë¡£ ¤³¤Î¤¿¤á¡¢$mon ¤Ï 0 ¤«¤é 11 ¤Þ¤Ç¡¢ $wday ¤Ï 0 ¤«¤é 6 ¤Þ¤Ç¤ÎÃͤò¼è¤ë¡£ EXPR ¤ò¾Êά¤¹¤ë¤È¡¢gmtime(time) ¤ò¼Â¹Ô¤¹¤ë¡£

localtime

`localtime(EXPR)'
`localtime EXPR'
time ´Ø¿ô¤¬ÊÖ¤¹·Á¼°¤Î»þ´Ö¤ò local timezone ¤È¤·¤Æ Í×ÁÇ¿ô 9 ¤ÎÇÛÎó¤ËÊÑ´¹¤¹¤ë¡£Åµ·¿Åª¤Ë°Ê²¼¤Î¤è¤¦¤ËÍѤ¤¤ë¡£
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
        localtime(time);
ÇÛÎó¤ÎÍ×ÁǤϤ¹¤Ù¤Æ¿ôÃͤǡ¢struct tm ¤«¤éľÀÜÆÀ¤é¤ì¤ë¤â¤Î¤Ç¤¢¤ë¡£ ¤³¤Î¤¿¤á¡¢$mon ¤Ï 0 ¤«¤é 11¡¢$wday ¤Ï 0 ¤«¤é 6 ¤ÎÃͤò¼è¤ë¡£ EXPR ¤ò¾Êά¤¹¤ë¤È¡¢localtime(time) ¤ò¼Â¹Ô¤¹¤ë¡£ time ¤Ë¤Ä¤¤¤Æ¤Ï See section ¿ô³Ø´Ø¿ô.

hex

`hex(EXPR)'
`hex EXPR'
EXPR ¤ò 16 ¿Êʸ»úÎó¤Ç¤¢¤ë¤È¸«¤Ê¤·¤Æ 10 ¿ÊÃͤòÊÖ¤¹ (0 ¤Þ¤¿¤Ï 0x ¤Ç»Ï¤Þ¤ëʸ»úÎó¤ÎÊÑ´¹¤Ë¤Ä¤¤¤Æ¤Ï oct() ¤ò»²¾È¡£)¡£ EXPR ¤ò¾Êά¤¹¤ë¤È¡¢$_ ¤ò»ÈÍѤ¹¤ë¡£

oct

`oct(EXPR)'
`oct EXPR'
EXPR ¤ÎÃͤò 8 ¿Êʸ»úÎó¤Ç¤¢¤ë¤È²ò¼á¤·¤Æ¤½¤Î 10 ¿ÊÃͤòÊÖ¤¹¡£ (EXPR ¤¬ 0x ¤Ç»Ï¤Þ¤ë¾ì¹ç¤ÏÂå¤ï¤ê¤Ë 16 ¿Êʸ»úÎó¤Ç¤¢¤ë¤È²ò¼á¤¹¤ë¡£) ¼¡¤ÎÎã¤Ç¤Ï¡¢É¸½àŪ¤Êµ­½Ò¤Ë¤è¤ë 10¡¢8¡¢16 ¿Ê¤ò°·¤¦¤³¤È¤¬¤Ç¤­¤ë¡£
$val = oct($val) if $val =~ /^0/;
EXPR ¤ò¾Êά¤·¤¿¾ì¹ç¡¢ $_ ¤ò»ÈÍѤ¹¤ë¡£

ord

`ord(EXPR)'
`ord EXPR'
EXPR ¤ÎºÇ½é¤Îʸ»ú¤Î ascii value ¤ò¿ôÃͤÇÊÖ¤¹¡£ EXPR ¤ò¾Êά¤¹¤ë¤È¡¢$_ ¤ò»ÈÍѤ¹¤ë¡£

vec

`vec(EXPR,OFFSET,BITS)'
ʸ»úÎó¤ò unsigned integer ¤Î¥Ù¥¯¥È¥ë¤È¤·¤Æ°·¤¤¡¢»ØÄꤷ¤¿¥Ó¥Ã¥È¤ÎÃͤòÊÖ¤¹¡£ ÂåÆþ¤â¤Ç¤­¤ë¡£BITS ¤Ï 2 ¤Î 1 ¾è¤«¤é 32 ¾è¤Þ¤Ç¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£ vec() ¤¬ÊÖ¤¹¥Ù¥¯¥È¥ë¤ÏÏÀÍý±é»»»Ò |¡¢&¡¢^ ¤òÍѤ¤¤Æ Áàºî¤Ç¤­¤ë¡£Î¾¥ª¥Ú¥é¥ó¥É¤¬Ê¸»úÎó¤Î¾ì¹ç¤Ï¥Ó¥Ã¥È¥Ù¥¯¥È¥ë±é»»¤Ç¤¢¤ë¤È²¾Äꤹ¤ë¡£ ¤³¤Î²ò¼á¤Ï¥×¥í¥°¥é¥à¤Ë¾¯¤Ê¤¯¤È¤â°ì¤Ä¤Î vec() ¤¬¤Ê¤¤¤È¤Ê¤µ¤ì¤Ê¤¤¡£ (¸Å¤¤¥×¥í¥°¥é¥à¤ò¼é¤ë¤¿¤á) ¥Ó¥Ã¥È¥Ù¥¯¥È¥ë¤òʸ»úÎó¤ä 0 ¤È 1 ¤ÎÇÛÎó¤ËÊÑ´¹¤¹¤ë¤Ë¤Ï¡¢ ¼¡¤Î¤è¤¦¤Ë¤¹¤ì¤Ð¤è¤¤¡£
$bits = unpack("b*", $vector);
@bits = split(//, unpack("b*", $vector));
Àµ³Î¤Ê¥Ó¥Ã¥ÈŤ¬¤ï¤«¤Ã¤Æ¤¤¤ë¤Ê¤é¡¢ * ¤ÎÂå¤ï¤ê¤Ë¤½¤ì¤ò»È¤¦¤³¤È¤¬¤Ç¤­¤ë¡£

¥Ç¡¼¥¿¹½Â¤ÊÑ´¹´Ø¿ô

pack

`pack(TEMPLATE,LIST)'
ÇÛÎó¤Þ¤¿¤ÏÃͤΥꥹ¥È¤ò°ú¿ô¤Ë¤È¤ê¡¢¥Ð¥¤¥Ê¥ê¹½Â¤ÂÎ¤Ë pack ¤¹¤ë¡£ ¹½Â¤ÂΤò´Þ¤àʸ»úÎó¤òÊÖ¤¹¡£TEMPLATE ¤Ï¤Ò¤È³¤­¤Îʸ»úÎó¤Ç¡¢ ³Æʸ»ú¤Ï°Ê²¼¤Î¤è¤¦¤ËÃͤΥª¡¼¥À¡¼¤ª¤è¤Ó¥¿¥¤¥×¤òɽ¤¹¡£
A    ¥¢¥¹¥­¡¼Ê¸»úÎó(¥¹¥Ú¡¼¥¹¤¬ pad ¤µ¤ì¤ë)
a    ¥¢¥¹¥­¡¼Ê¸»úÎó(¥Ì¥ë¤¬ pad ¤µ¤ì¤ë)
c    signed char
C    unsigned char
s    signed short
S    unsigned short
i    signed integer
I    unsigned integer
l    signed long
L    unsigned long
n    short("network" ¥ª¡¼¥À¡¼)
N    long("network" ¥ª¡¼¥À¡¼)
f    ñÀºÅÙÉâÆ°¾®¿ôÅÀ(native format)
d    ÇÜÀºÅÙÉâÆ°¾®¿ôÅÀ(     ¡·      )
p    string ¤Ø¤Î¥Ý¥¤¥ó¥¿
x    ¥Ì¥ë¥Ð¥¤¥È
X    1 ¥Ð¥¤¥È¸åÂह¤ë
@    ÀäÂаÌÃ֤ޤǥ̥ë¤ÇËä¤á¤ë
u    uuencode ¤µ¤ì¤¿Ê¸»úÎó
b    ¥Ó¥Ã¥Èʸ»úÎó
     (vec() ¤Î¤è¤¦¤Ê¡¢¾º½ç¤Î¥Ó¥Ã¥È¥ª¡¼¥À¡¼(ascending bit order))
B    ¥Ó¥Ã¥Èʸ»úÎó(¹ß½ç¤Î¥Ó¥Ã¥È¥ª¡¼¥À¡¼(descending bit order))
h    16¿Êʸ»úÎó(Äã nybble ¤¬Àè¤ËÍè¤ë)
H    16¿Êʸ»úÎó(¹â nybble ¤¬Àè¤ËÍè¤ë)
¥ª¥×¥·¥ç¥ó¤È¤·¤Æ¿ô»ú¤ò³Æʸ»ú¤Î¸å¤Ë¤Ä¤±¤Æ¡¢·«¤êÊÖ¤·¿ô¤ò»ØÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤ë¡£ `a'¡¢`A'¡¢`b'¡¢`B'¡¢`h'¡¢`H' °Ê³°¤Î¥¿¥¤¥×¤Ç¤Ï¡¢ »ØÄꤵ¤ì¤¿¿ô¤ÎÃͤò LIST ¤«¤é¼è¤ë¡£ ¥ê¥Ô¡¼¥ÈÃͤȤ·¤Æ * ¤ò»È¤¦¤È»Ä¤êÁ´Éô¤ò¼¨¤¹¡£ `a' ¤È `A' ¤Ç¤Ï¡¢Ãͤϰì¤Ä¤Ç¡¢»ØÄꤵ¤ì¤¿Ä¹¤µ¤Î°ì¤Ä¤Îʸ»úÎó¤È¤·¤Æ¡¢ ɬÍפʤé¥Ì¥ë¤ä¥¹¥Ú¡¼¥¹¤ò pad ¤¹¤ë¡£ (unpack ¤ÎºÝ¤Ë¤Ï¡¢ `A' ¤Ï¸å¤Ë³¤¯¥¹¥Ú¡¼¥¹¤ä¥Ì¥ë¤ò¼è¤ê½ü¤¯¤¬¡¢ `a' ¤Î¾ì¹ç¤Ï¤½¤¦¤Ç¤Ï¤Ê¤¤¡£) ƱÍͤˡ¢`b' ¤È `B' ¤Ï»ØÄꤷ¤¿¥Ó¥Ã¥È¿ôʬ¤Îʸ»úÎó¤ò pack ¤¹¤ë¡£ `h' ¤È `H' ¤Ï»ØÄꤷ¤¿¿ô¤Î nybbles ¤ò pack ¤¹¤ë¡£ ¼Â¿ô(ñÀºÅÙ¡¢ÇÜÀºÅÙ)¤Ï native machine format ¤Î¤ß¤Ç¤¢¤ë¡£ ÉâÆ°¾®¿ôÅÀ¤Î¥Õ¥©¡¼¥Þ¥Ã¥È¤Ë¤Ï¤¤¤í¤¤¤í¤¢¤ê¡¢ ɸ½à¤Î network ɽ¸½¤¬¤Ê¤¤¤Î¤Ç¡¢¸ò´¹¤¹¤ë¤³¤È¤Ï¤Ç¤­¤Ê¤¤¡£ ¤³¤Î¤¿¤á¡¢¤¢¤ë¥Þ¥·¥ó¤Ç pack ¤µ¤ì¤¿ÉâÆ°¾®¿ôÅÀ¥Ç¡¼¥¿¤Ï ¾¤Î¥Þ¥·¥ó¤Ç¤ÏÆɤळ¤È¤¬¤Ç¤­¤Ê¤¤ --- ¤¿¤È¤¨Î¾Êý¶¦ IEEE ¤Î floating point arithmetic ¤ò»È¤Ã¤Æ¤¤¤¿¤È¤·¤Æ¤â (¥á¥â¥êɽ¸½¤Î endian-ness ¤Ï IEEE ¤Î¥¹¥Ú¥Ã¥¯¤Ë¤Ï¤Ê¤¤¤«¤é)¡£ perl ¤ÏÆâÉô¤ÎÁ´¿ôÃÍ·×»»¤ËÇÜÀºÅÙ¤òÍѤ¤¤Æ¤¤¤ë¤Î¤Ç¡¢ double -> float -> double ¤È¤¤¤¦ÊÑ´¹¤ò¤¹¤ë¤ÈÀºÅÙ¤¬°­¤¯¤Ê¤ë (¤¹¤Ê¤ï¤Á¡¢unpack("f", pack("f", $foo)) ¤Ï ÉáÄÌ $foo ¤È°ìÃפ·¤Ê¤¤)¤³¤È¤ËÃí°Õ¡£
$foo = pack("cccc",65,66,67,68);
# foo ¤Ï "ABCD" ¤È¤Ê¤ë
$foo = pack("c4",65,66,67,68);
# Ʊ¤¸¤³¤È

$foo = pack("ccxxcc",65,66,67,68);
# foo ¤Ï "AB\0\0CD" ¤È¤Ê¤ë

$foo = pack("s2",1,2);
# ¥ê¥È¥ë¡¦¥¨¥ó¥Ç¥£¥¢¥ó¤Ç¤Î "\1\0\2\0"
# ¥Ó¥Ã¥°¡¦¥¨¥ó¥Ç¥£¥¢¥ó¤Ç¤Î "\0\1\0\2"

$foo = pack("a4","abcd","x","y","z");
# "abcd"

$foo = pack("aaaa","abcd","x","y","z");
# "axyz"

$foo = pack("a14","abcdefg");
# "abcdefg\0\0\0\0\0\0\0"

$foo = pack("i9pl", gmtime);
# ¼ÂºÝ¤Î¹½Â¤ÂÎ tm (»ä¤Î¥·¥¹¥Æ¥à¤Ç¤Ï)

sub bintodec {
    unpack("N", pack("B32", substr("0" x 32 . shift, -32)));
}
unpack ´Ø¿ô¤Ç¤â¡¢Æ±¤¸¥Æ¥ó¥×¥ì¡¼¥È¤òÍѤ¤¤ë¤³¤È¤¬¤Ç¤­¤ë¡£

unpack

`unpack(TEMPLATE,EXPR)'
unpack ¤Ï pack ¤ÎµÕ¤ò¹Ô¤¦:
¤¢¤ë¹½Â¤ÂΤò¼¨¤¹Ê¸»úÎ󤫤éÇÛÎóÃͤò¼è¤ê½Ð¤¹¡£ (¥¹¥«¥é¡¼¥³¥ó¥Æ¥­¥¹¥È¤Ç¤Ï¡¢À¸À®¤·¤¿ºÇ½é¤ÎÃͤΤߤòÊÖ¤¹¡£) TEMPLATE ¤Ï pack´Ø¿ô ¤ÈƱ¤¸¥Õ¥©¡¼¥Þ¥Ã¥È¤Ç¤¢¤ë¡£ °Ê²¼¤Ï substring ¤ò¹Ô¤¦¥µ¥Ö¥ë¡¼¥Á¥ó¤ÎÎã¤Ç¤¢¤ë¡£
sub substr {
     local($what,$where,$howmuch) = @_;
     unpack("x$where a$howmuch", $what);
}
¤½¤·¤Æ¡¢
sub ord { unpack("c",$_[0]); }
¤µ¤é¤Ë¡¢¥Õ¥£¡¼¥ë¥É¤Ë %<¿ô»ú> ¤È¤¤¤¦Åº¤¨»ú¤ò¤Ä¤±¤ë¤È¡¢ ¥¢¥¤¥Æ¥à¤½¤Î¤â¤Î¤ÎÂå¤ï¤ê¤Ë¡¢¥¢¥¤¥Æ¥à¤Î<¿ô»ú>¥Ó¥Ã¥È¤Î¥Á¥§¥Ã¥¯¥µ¥à¤¬ÆÀ¤é¤ì¤ë¡£ ¥Ç¥Õ¥©¥ë¥È¤Ï 16 ¥Ó¥Ã¥È¥Á¥§¥Ã¥¯¥µ¥à¤Ç¤¢¤ë¡£ Î㤨¤Ð¡¢¼¡¤ÎÎã¤Ç¤Ï System V ¤Î sum ¥×¥í¥°¥é¥à¤ÈƱ¤¸Ãͤ¬ÆÀ¤é¤ì¤ë¡£
while(<>) {
    $checksum += unpack("%16C*", $_);
}
$checksum %= 65536;
See section pack.

ʸ»úÎó´Ø¿ô

chop

`chop(LIST)'
`chop(VARIABLE)'
`chop VARIABLE'
`chop'
ʸ»úÎó¤ÎºÇ¸å¤Îʸ»ú¤òÍî¤È¤·¤Æ¤½¤Îʸ»úÎó¤òÊÖ¤¹¡£ ¼ç¤ËÆþÎÏʸ»úÎ󤫤éºÇ¸å¤Î²þ¹Ôʸ»ú¤ò½ü¤¯¤Î¤Ë»È¤¦¤¬¡¢ ʸ»úÎó¤ÎÁöºº¤ä¥³¥Ô¡¼¤ò¹Ô¤ï¤Ê¤¤¤Î¤Ç¡¢s/\n// ¤è¤ê¤â¸úΨ¤¬¤è¤¤¡£ ÊÑ¿ô¤ò¾Êά¤·¤¿¾ì¹ç¡¢$_ ¤ò»È¤¦¡£
while (<>) {
     chop;     # ºÇ¸å¤Î \n ¤ò¼è¤ë
     @array = split(/:/);
     ...
º¸ÊÕÃͤǤ¢¤ì¤Ð°ú¿ô¤Ï²¿¤Ç¤â¤¤¤¤¡£
chop($cwd = `pwd`);
chop($answer = <STDIN>);
¥ê¥¹¥È¤ò chop ¤·¤¿¾ì¹ç¤Ï¡¢Á´Í×ÁǤò chop ¤·¡¢ ºÇ¸å¤Ë chop ¤·¤¿Ê¸»ú¤òÊÖ¤¹¡£

crypt

`crypt(PLAINTEXT,SALT)'
ʸ»úÎó¤ò C ¥é¥¤¥Ö¥é¥ê¤Î crypt() ¤ÈÁ´¤¯Æ±¤¸¤è¤¦¤Ë°Å¹æ²½¤¹¤ë¡£ ¥Ñ¥¹¥ï¡¼¥É¥Õ¥¡¥¤¥ëÃæ¤Î¤¯¤À¤é¤Ê¤¤¥Ñ¥¹¥ï¡¼¥É¤ò¥Á¥§¥Ã¥¯¤¹¤ë¤Î¤ËÊØÍø¤Ç¤¢¤ë¡£ Çò¤¤Ë¹»Ò¤ÎÁ±¶Ì¤À¤±¤¬¤½¤ì¤ò¤¹¤ë¤Ù¤­¤À¡£

eval

`eval(EXPR)'
`eval EXPR'
`eval BLOCK'
EXPR ¤ò parse ¤·¡¢perl ¥×¥í¥°¥é¥à¤Ç¤¢¤ë¤È¤ß¤Ê¤·¤Æ¼Â¹Ô¤¹¤ë¡£ ¸½ºß¤Î perl ¥×¥í¥°¥é¥à¤Î´Ä¶­¤Ç¼Â¹Ô¤µ¤ì¤ë¤Î¤Ç¡¢ ÊÑ¿ô¡¢¥µ¥Ö¥ë¡¼¥Á¥ó¡¢¥Õ¥©¡¼¥Þ¥Ã¥ÈÄêµÁ¤Ï¸å¤Þ¤Ç»Ä¤ë¡£ ¥µ¥Ö¥ë¡¼¥Á¥ó¤ÈƱ¤¸¤¯¡¢É¾²Á¤·¤¿ºÇ¸å¤Î expression ¤ÎÃͤ¬Ê֤롣 ¥·¥ó¥¿¥Ã¥¯¥¹¥¨¥é¡¼¤Þ¤¿¤Ï¥é¥ó¥¿¥¤¥à¥¨¥é¡¼¤¬¤¢¤Ã¤¿¾ì¹ç¡¢ ¤Þ¤¿¤Ï die ʸ¤¬¼Â¹Ô¤µ¤ì¤¿¾ì¹ç¡¢ eval ¤Ï undefined value ¤òÊÖ¤·¡¢ $@ ¤Ë¤Ï¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤¬¥»¥Ã¥È¤µ¤ì¤ë¡£ ¥¨¥é¡¼¤¬¤Ê¤±¤ì¤Ð $@ ¤Ï¥Ì¥ë¤Ç¤¢¤ë¤³¤È¤¬Êݾڤµ¤ì¤Æ¤¤¤ë¡£ EXPR ¤¬¾Êά¤µ¤ì¤¿¾ì¹ç¤Ï¡¢$_ ¤òɾ²Á¤¹¤ë¡£ expression ¤ÎºÇ¸å¤Ë¥»¥ß¥³¥í¥ó¤¬¤â¤·¤¢¤ì¤Ð¡¢expression ¤«¤é½ü¤«¤ì¤ë¡£ $@ ¤Ë¤Ä¤¤¤Æ¤Ï See section @hbox{@hbox to 1.6em{@tt@$@@hfil} : ºÇ¸å¤Ë¹Ô¤Ã¤¿ eval ¤Î¥·¥ó¥¿¥Ã¥¯¥¹¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸}. eval ¤ÏÃ×̿Ū¥¨¥é¡¼¤ò¥È¥é¥Ã¥×¤¹¤ë¤Î¤Ç¡¢ ¤¢¤ëµ¡Ç½(Î㤨¤Ð dbmopen ¤ä symlink)¤¬ ¥¤¥ó¥×¥ê¥á¥ó¥È¤µ¤ì¤Æ¤¤¤ë¤«¤É¤¦¤«¤ò·èÄꤹ¤ë¤Î¤ËÊØÍø¤Ç¤¢¤ë¡£ ¤Þ¤¿¡¢eval ¤Ï¡¢perl ¤ÎÎã³°¥È¥é¥Ã¥×µ¡¹½(exception trapping mechanism) ¤Ç¤â¤¢¤ë¡£¤³¤ÎÎã³°¤òµ¯¤³¤¹¤¿¤á¤Ë¤Ï die ±é»»»Ò¤òÍѤ¤¤ë¡£ ¼Â¹Ô¤¹¤ë¥³¡¼¥É¤¬ÊѲ½¤·¤Ê¤¤¤Î¤Ç¤¢¤ì¤Ð¡¢ eval-BLOCK ·Á¼°¤ò»È¤¦¤³¤È¤Ë¤è¤ê¡¢ Ëè²ó¥³¥ó¥Ñ¥¤¥ë¤·Ä¾¤¹ÉÔÍø±×¤òÈï¤ë¤³¤È¤Ê¤¯ ¼Â¹Ô»þ¤Î¥¨¥é¡¼¤ò¥È¥é¥Ã¥×¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£ ¥¨¥é¡¼¤Ï¡¢¤â¤·¤¢¤ì¤Ð¡¢Æ±ÍÍ¤Ë $@ ¤Ë¥»¥Ã¥È¤µ¤ì¤ë¡£ ¥·¥ó¥°¥ë¥¯¥©¡¼¥È¤µ¤ì¤¿Ê¸»úÎó(EXPR)¤ò eval ¤¹¤ë¤Î¤âƱÍͤθú²Ì¤¬¤¢¤ë¤¬¡¢ eval-EXPR ¤Ï¥·¥ó¥¿¥Ã¥¯¥¹¥¨¥é¡¼¤ò¼Â¹Ô»þ¤Ë $@ ¤ËÊÖ¤¹¤Î¤ËÂФ·¡¢ eval-BLOCK ¤Ï¥·¥ó¥¿¥Ã¥¯¥¹¥¨¥é¡¼¤ò¥³¥ó¥Ñ¥¤¥ë»þ¤ËÊÖ¤¹ÅÀ¤¬°Û¤Ê¤ë¡£ eval-EXPR ·Á¼°¤Ï¡¢ ¤½¤Î¼Â¹Ô¤¬ºÇ½é¤ËÀ®¸ù¤·¤¿»þÅÀ¤Ç eval-BLOCK ·Á¼°¤ËºÇŬ²½¤µ¤ì¤ë¡£ (ʸ»úÎóÃÖ´¹¤Ë¤ª¤¤¤Æ e ½¤¾þ»Ò¤òÍѤ¤¤¿¾ì¹ç¡¢ ÃÖ´¹Â¦¤Ï¥·¥ó¥°¥ë¥¯¥©¡¼¥È¤µ¤ì¤¿Ê¸»úÎó¤Ç¤¢¤ë¤È¸«¤Ê¤µ¤ì¤ë¤Î¤Ç¡¢ ƱÍͤκÇŬ²½¤¬¤³¤Î¾ì¹ç¤Ë¤â¤Ê¤µ¤ì¤ë¡£) Îã:
# 0 ½ü»»¤òÃ×̿Ū¥¨¥é¡¼¤Ë¤·¤Ê¤¤
eval { $answer = $a / $b; }; warn $@ if $@;

# ºÇ½é¤Ë»È¤Ã¤¿¸å¡¢Æ±¤¸¤â¤Î¤ËºÇŬ²½¤µ¤ì¤ë
eval '$answer = $a / $b'; warn $@ if $@;

# ¥³¥ó¥Ñ¥¤¥ë»þ¥¨¥é¡¼
eval { $answer = };

# ¼Â¹Ô»þ¥¨¥é¡¼
eval '$answer =';	# $@ ¤ò¥»¥Ã¥È¤¹¤ë

index

`index(STR,SUBSTR,POSITION)'
`index(STR,SUBSTR)'
STR Æâ¤Ç SUBSTR ¤¬ POSITION ʸ»úÌÜ ¤Þ¤¿¤Ï¤½¤ì°Ê¹ß¤ËºÇ½é¤Ë¸½¤ì¤ë°ÌÃÖ¤òÊÖ¤¹¡£ POSITION ¤ò¾Êά¤·¤¿¾ì¹ç¤Ïʸ»úÎó¤ÎºÇ½é¤«¤é¸¡º÷¤¹¤ë¡£ ÊÖ¤êÃͤΥ١¼¥¹¤Ï 0 ¤Þ¤¿¤Ï $[ ¤Ë¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤ì¤Ð¤½¤ÎÃͤǤ¢¤ë¡£ SUBSTR ¤¬¸«¤Ä¤«¤é¤Ê¤±¤ì¤Ð¡¢¥Ù¡¼¥¹¤«¤é 1 ¤ò°ú¤¤¤¿ÃͤòÊÖ¤¹¡£ Ä̾ï -1 ¤Ç¤¢¤ë¡£ See section @hbox{@hbox to 1.6em{@tt@$[@hfil} : ÇÛÎó¤ÎºÇ½é¤ÎÍ×ÁǤ䡢¥µ¥Ö¥¹¥È¥ê¥ó¥°¤ÎºÇ½é¤Îʸ»ú¤Îź¤¨»ú}.

length

`length(EXPR)'
`length EXPR'
EXPR ¤ÎÃͤÎʸ»úÎóŤòÊÖ¤¹¡£ EXPR ¤ò¾Êά¤¹¤ë¤È¡¢$_ ¤ÎŤµ¤òÊÖ¤¹¡£

rindex

`rindex(STR,SUBSTR,POSISION)'
`rindex(STR,SUBSTR)'
index ¤ÈƱ¤¸¤è¤¦¤ÊÆ°ºî¤ò¤¹¤ë¤¬¡¢ °ã¤¤¤Ï STR Æâ¤ËºÇ¸å¤Ë¸½¤ì¤ë SUBSTR ¤Î°ÌÃÖ¤òÊÖ¤¹¤³¤È¤Ç¤¢¤ë¡£ POSITION ¤ò»ØÄꤹ¤ë¤È¡¢ ¤½¤Î°ÌÃÖ¤Þ¤¿¤Ï¤½¤ì¤è¤êÁ°¤ÇºÇ¸å¤Ë¸½¤ì¤ë°ÌÃÖ¤òÊÖ¤¹¡£ See section index.

substr

`substr(EXPR,OFFSET,LEN)'
`substr(EXPR,OFFSET)'
EXPR ¤«¤éʸ»úÎó¤ò¼è¤ê½Ð¤·ÊÖ¤¹¡£1 ʸ»úÌܤϥª¥Õ¥»¥Ã¥È 0 ¤Ç¤¢¤ë¤¬¡¢ $[ ¤Ë¥»¥Ã¥È¤¹¤ë¤³¤È¤ÇÊѤ¨¤ë¤³¤È¤¬¤Ç¤­¤ë¡£OFFSET ¤¬Éé¤Î¾ì¹ç¤Ï¡¢ ʸ»úÎó¤Î½ª¤ï¤ê¤«¤é¤½¤Î¿ôʬÌá¤Ã¤¿½ê¤«¤é»Ï¤á¤ë¡£ LEN ¤ò¾Êά¤¹¤ë¤È¡¢Ê¸»úÎó¤Î»Ä¤êÁ´Éô¤òÊÖ¤¹¡£ substr() ´Ø¿ô¤Ïº¸ÊÕÃͤȤ·¤Æ»È¤¦¤³¤È¤â¤Ç¤­¤ë¤¬¡¢ ¤³¤Î¾ì¹ç EXPR ¤¬ º¸ÊÕÃͤǤʤ¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£ LEN ¤è¤ê¤âû¤¤¤â¤Î¤òÂåÆþ¤¹¤ë¤È¡¢¤½¤Îʸ»úÎó¤Ïû¤¯¤Ê¤ê¡¢ LEN ¤è¤ê¤âŤ¤¤â¤Î¤òÂåÆþ¤¹¤ë¤È¤½¤ì¤Ë¹ç¤ï¤»¤ÆŤ¯¤Ê¤ë¡£ ʸ»úÎó¤ÎŤµ¤òÊѤ¨¤Ê¤¤¾ì¹ç¤Ï sprintf ¤òÍѤ¤¤Æ ¥Ñ¥Ç¥£¥ó¥°¤Þ¤¿¤ÏÀڼΤƤò¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£ See section @hbox{@hbox to 1.6em{@tt@$[@hfil} : ÇÛÎó¤ÎºÇ½é¤ÎÍ×ÁǤ䡢¥µ¥Ö¥¹¥È¥ê¥ó¥°¤ÎºÇ½é¤Îʸ»ú¤Îź¤¨»ú}.

ÇÛÎó & ¥ê¥¹¥È¤ò°·¤¦´Ø¿ô

delete

`delete $ASSOC{KEY}'
»ØÄꤷ¤¿Ï¢ÁÛÇÛÎ󤫤顢»ØÄꤷ¤¿Ãͤòºï½ü¤¹¤ë¡£ ºï½ü¤µ¤ì¤¿ÃͤòÊÖ¤¹¤«¡¢²¿¤âºï½ü¤µ¤ì¤Ê¤«¤Ã¤¿¾ì¹ç¤Ï undefined value ¤òÊÖ¤¹¡£ dbm ¥Õ¥¡¥¤¥ë¤Ë bind ¤µ¤ì¤¿Ï¢ÁÛÇÛÎó¤òºï½ü¤¹¤ë¤È¡¢ dbm ¥Õ¥¡¥¤¥ë¤Î¥¨¥ó¥È¥ê¤òºï½ü¤¹¤ë¡£ °Ê²¼¤ÎÎã¤Ç¤ÏÏ¢ÁÛÇÛÎó¤ÎÁ´¤Æ¤ÎÃͤòºï½ü¤¹¤ë¡£
foreach $key (keys %ARRAY) {
     delete $ARRAY{$key};
}
(¤¬¡¢reset ¥³¥Þ¥ó¥É¤ò»È¤Ã¤¿Êý¤¬Â®¤¤¤À¤í¤¦¡£ undef %ARRAY ¤Ï¤â¤Ã¤È®¤¤¤À¤í¤¦¡£)

each

`each(ASSOC_ARRAY)'
`each ASSOC_ARRAY'
Ï¢ÁÛÇÛÎó¤Î¼¡¤ÎÃͤΡ¢¥­¡¼(key)¤ÈÃÍ(value)¤«¤é¤Ê¤ë 2 Í×ÁǤÎÇÛÎó¤òÊÖ¤¹¡£ ½¾¤Ã¤Æ¡¢·«¤êÊÖ¤·¤¬¤Ç¤­¤ë¡£¥¨¥ó¥È¥ê¡¼¤Ï¥é¥ó¥À¥à¤Ê½ç½ø¤ÇÊ֤äƤ¯¤ë¡£ Á´ÇÛÎó¤òÆɤ߽ª¤¨¤ë¤È¡¢ ¥Ì¥ëÇÛÎó¤¬ÊÖ¤ë(¤³¤ì¤ÏÂåÆþ¤µ¤ì¤¿¾ì¹ç¤Ï FALSE ¤¹¤Ê¤ï¤Á 0 ¤Ë¤Ê¤ë)¡£ ¤³¤Î¸å³¤±¤Æ¥³¡¼¥ë¤¹¤ë¤È·«¤êÊÖ¤·¤òºÆ¤Ó»Ï¤á¤ë¡£ ·«¤êÊÖ¤·¾ðÊó¤ÏÁ´¤Æ¤ÎÇÛÎó¤òÆɤळ¤È¤Ë¤è¤Ã¤Æ¤Î¤ß½é´ü²½¤µ¤ì¤ë¡£ ·«¤êÊÖ¤·¤ÎÅÓÃæ¤Ç¤ÏÇÛÎó¤òÊѹ¹¤·¤Æ¤Ï¤¤¤±¤Ê¤¤¡£ ·«¤êÊÖ¤·¾ðÊó¤Ï³ÆÏ¢ÁÛÇÛÎó¤Ë°ì¤Ä¤º¤Ä¤¢¤ê¡¢ ¥×¥í¥°¥é¥àÃæ¤Î Á´¤Æ¤Î each(), key(), values() ´Ø¿ô¥³¡¼¥ë¤Ç¶¦Í­¤µ¤ì¤ë¡£ ¼¡¤ÎÎã¤Ç¤Ï printenv ¤Î¤è¤¦¤Ë´Ä¶­¤ò¥×¥ê¥ó¥È¥¢¥¦¥È¤¹¤ë¤¬¡¢½çÈÖ¤¬°Û¤Ê¤ë¡£
while (($key,$value) = each %ENV) {
     print "$key=$value\n";
}
See section keys, ¤ª¤è¤Ó See section values.

grep

`grep(EXPR,LIST)'
LIST ¤ÎÁ´Í×ÁǤˤĤ¤¤Æ EXPR ¤òɾ²Á¤·(³ÆÍ×ÁǤò $_ ¤Ë¥»¥Ã¥È¤·¤Ê¤¬¤é)¡¢ expression ¤¬ true ¤Ç¤¢¤ë¤Èɾ²Á¤µ¤ì¤¿Í×ÁǤ«¤é¤Ê¤ëÇÛÎó¤òÊÖ¤¹¡£ ¥¹¥«¥é¡¼¤Î¥³¥ó¥Æ¥­¥¹¥È¤Ç¤Ï¡¢expression ¤¬ true ¤È¤Ê¤Ã¤¿²ó¿ô¤òÊÖ¤¹¡£
@foo = grep(!/^#/, @bar);    # ¥³¥á¥ó¥È¤ò̵»ë¤¹¤ë
Ãí°Õ: $_ ¤ÏÇÛÎóÃͤؤλ²¾È¤È¤Ê¤Ã¤Æ¤¤¤ë¤Î¤Ç¡¢ ÇÛÎóÍ×ÁǤòÊѹ¹¤¹¤ë¤Î¤ËÍѤ¤¤ë¤³¤È¤¬¤Ç¤­¤ë¡£¤³¤ì¤ÏÊØÍø¤Ç¤¢¤ë°ìÊý¡¢ LIST ¤¬Ì¾Á°¤Î¤Ä¤¤¤¿ÇÛÎó¤Ç¤Ê¤¤¾ì¹ç¤Ë¤Ï¡¢ ¤Á¤ç¤Ã¤ÈÊѤʷë²Ì¤òÊÖ¤¹¤³¤È¤¬¤¢¤ë¡£

join

`join(EXPR,LIST)'
`join(EXPR,ARRAY)'
LIST ¤Þ¤¿¤Ï ARRAY ¤Î¸Ä¡¹¤Îʸ»úÎó¤ò EXPR ¤ÎÃͤǶèÀڤä¿°ì¤Ä¤Îʸ»úÎó¤Ë¤¹¤ë¡£
$_ = join(':',$login,$passwd,$uid,$gid,$gcos,$home,$shell);
See section split.

keys

`keys(ASSOC_ARRAY)'
`keys ASSOC_ARRAY'
»ØÄꤵ¤ì¤¿Ï¢ÁÛÇÛÎó¤ÎÁ´¤Æ¤Î¥­¡¼¤«¤é¤Ê¤ëÄ̾ï¤ÎÇÛÎó¤òÊÖ¤¹¡£ ¥­¡¼¤ÏÁ´¤¯¥é¥ó¥À¥à¤Ê½ç½ø¤ÇÊÖ¤µ¤ì¤ë¤¬¡¢ values() ¤ä each() ´Ø¿ô¤Î½ÐÎϤÈƱ¤¸¤Ç¤¢¤ë (Ï¢ÁÛÇÛÎó¤¬Êѹ¹¤µ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð)¡£ °Ê²¼¤Ï´Ä¶­¤ò½ÐÎϤ¹¤ë¤Þ¤¿Ê̤ÎÊýË¡¤Ç¤¢¤ë¡£
@keys = keys %ENV;
@values = values %ENV;
while ($#keys >= 0) {
     print pop(@keys), '=', pop(@values), "\n";
}
¤Þ¤¿¤Ï¡¢¥­¡¼¤Ç¥½¡¼¥È¤·¤Æ¤ß¤ë¤È¡¢
foreach $key (sort(keys %ENV)) {
     print $key, '=', $ENV{$key}, "\n";
}
See section each, ¤ª¤è¤Ó See section values.

pop

`pop(ARRAY)'
`pop ARRAY'
ÇÛÎó¤ÎºÇ¸å¤ÎÃͤòÊÖ¤·¡¢ÇÛÎó¤ò 1 ¸º¤é¤¹¡£
$tmp = $ARRAY[$#ARRAY--];
¤ÈƱ¤¸¸ú²Ì¤¬¤¢¤ë¡£ÇÛÎó¤ËÍ×ÁǤ¬°ì¤Ä¤â¤Ê¤¤¾ì¹ç¤Ï undefined value ¤òÊÖ¤¹¡£ See section push.

push

`push(ARRAY,LIST)'
ARRAY(@ ¤ÏÉÕ¤±¤Ê¤¯¤Æ¤è¤¤)¤ò¥¹¥¿¥Ã¥¯¤Î¤è¤¦¤Ë°·¤¤¡¢ LIST ¤ÎÃͤò ARRAY ¤ÎºÇ¸å¤ËÄɲ乤롣 ARRAY ¤ÎŤµ¤Ï LIST ¤ÎŤµÊ¬Áý¤¨¤ë¡£
for $value (LIST) {
     $ARRAY[++$#ARRAY] = $value;
}
¤ÈƱ¤¸¸ú²Ì¤ò»ý¤Ä¤¬¡¢¤è¤ê¸úΨ¤¬¤è¤¤¡£ See section pop.

reverse

`reverse(LIST)'
`reverse LIST'
ÇÛÎó¤Î¥³¥ó¥Æ¥­¥¹¥È¤Ç¤Ï¡¢LIST ¤ÎÍ×ÁǤòµÕ½ç¤Ë¤·¤¿ÇÛÎóÃͤòÊÖ¤¹¡£ ¥¹¥«¥é¡¼¤Î¥³¥ó¥Æ¥­¥¹¥È¤Ç¤Ï¡¢ LIST ¤ÎºÇ½é¤ÎÍ×ÁǤΥХ¤¥ÈÎó¤òµÕ¤Ë¤·¤¿Ê¸»úÎó¤òÊÖ¤¹¡£

shift

`shift(ARRAY)'
`shift ARRAY'
`shift'
ÇÛÎó¤ÎºÇ½é¤ÎÃͤò¼è¤ê½Ð¤·¤Æ¤½¤ì¤òÊÖ¤¹¡£ ¤½¤·¤Æ¡¢ÇÛÎó¤ÎŤµ¤ò 1 ¸º¤é¤·¤ÆÁ´Í×ÁǤò¤º¤é¤¹¡£ ÇÛÎó¤ËÍ×ÁǤ¬¤Ê¤¤¾ì¹ç¡¢undefined value ¤òÊÖ¤¹¡£ ARRAY ¤ò¾Êά¤¹¤ë¤È¡¢ ¥á¥¤¥ó¥×¥í¥°¥é¥à¤Ç¤Ï @ARGV ¤ò shift ¤·¡¢ ¥µ¥Ö¥ë¡¼¥Á¥ó¤Ç¤Ï @_ ¤ò shift ¤¹¤ë¡£ (¤³¤ì¤Ï lexically(?) ¤Ë·èÄꤵ¤ì¤ë¡£) unshift()¡¢push()¡¢pop() ¤â»²¾È¤Î¤³¤È¡£ shift() ¤È unshift() ¤Ï¡¢ push() ¤È pop() ¤¬ÇÛÎó¤Î±¦¤Ë¤Ä¤¤¤Æ¹Ô¤¦¤Î¤ÈƱ¤¸¤³¤È¤ò ÇÛÎó¤Îº¸¤Ë¤Ä¤¤¤Æ¹Ô¤¦¡£ See section unshift, See section push, ¤ª¤è¤Ó See section pop.

sort

`sort(SUBROUTINE LIST)'
`sort(LIST)'
`sort SUBROUTINE LIST'
`sort BLOCK LIST'
`sort LIST'
LIST ¤ò¥½¡¼¥È¤·¡¢¥½¡¼¥È¤µ¤ì¤¿ÇÛÎó¤òÊÖ¤¹¡£ ÇÛÎóÃæ¤Î¸ºß¤·¤Ê¤¤ÃͤϽü¤«¤ì¤ë¡£ SUBROUTINE ¤Þ¤¿¤Ï BLOCK ¤ò¾Êά¤¹¤ë¤È¡¢ ɸ½àŪ¤Êʸ»úÎóÈæ³Ó¤Î½ç¤Ç¥½¡¼¥È¤¹¤ë¡£ SUBROUTINE ¤ò»ØÄꤹ¤ë¤È¤­¤Ï¡¢ÇÛÎó¤ÎÍ×ÁǤÎʤÙÂؤ¨¤«¤¿¤Ë±þ¤¸¤Æ¡¢ 0 ¤è¤ê¾®¡¢0¡¢0 ¤è¤êÂç¤ÎÀ°¿ôÃͤòÊÖ¤¹¥µ¥Ö¥ë¡¼¥Á¥ó¤Î̾Á°¤ò»ØÄꤹ¤ë¡£ (¤³¤Î¤¿¤á¤Î¥µ¥Ö¥ë¡¼¥Á¥ó¤Ë¤ª¤¤¤Æ¤Ï¡¢ <=> ¤ä cmp ¤È¤¤¤Ã¤¿±é»»»Ò¤¬ÂçÊÑÊØÍø¤Ç¤¢¤ë¡£) SUBROUTINE ¤Ï¥¹¥«¥é¡¼ÊÑ¿ô¤Î̾Á°¤Ç¤â¤è¤¤¡£ ¤³¤Î¾ì¹ç¤½¤ÎÊÑ¿ô¤ÎÃͤ¬»ÈÍѤ¹¤ë¥µ¥Ö¥ë¡¼¥Á¥ó¤Î̾Á°¤òɽ¤¹¡£ ¥µ¥Ö¥ë¡¼¥Á¥ó̾¤ÎÂå¤ï¤ê¤ËǤ°Õ¤Î BLOCK ¤ò»ØÄꤷ¤Æ¡¢ ¥¤¥ó¥é¥¤¥ó¤Î¥½¡¼¥È¥µ¥Ö¥ë¡¼¥Á¥ó¤È¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£ ¸úΨ¤òÎɤ¯¤¹¤ë¤¿¤á¡¢Ä̾ï¤Î¥µ¥Ö¥ë¡¼¥Á¥ó¥³¡¼¥ë¤ò¤È¤Ð¤·¤Æ¤¤¤ë¡£ ¤³¤Î¤¿¤á¡¢¼¡¤Î±Æ¶Á¤¬¤¢¤ë¡£ ¥µ¥Ö¥ë¡¼¥Á¥ó¤ÏºÆµ¢Åª¤Ç¤¢¤Ã¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£ ¤Þ¤¿¡¢Èæ³Ó¤µ¤ì¤ë 2 Í×ÁÇ¤Ï @_ ¤òÄ̤¸¤Æ¤Ç¤Ï¤Ê¤¯¡¢ $a ¤È $b ¤òÄ̤¸¤Æ¥µ¥Ö¥ë¡¼¥Á¥ó¤ËÅϤµ¤ì¤ë¡£(°Ê²¼¤ÎÎã¤ò»²¾È¡£) ¤³¤ì¤é¤Ï»²¾ÈÅϤ·¤Ç¤¢¤ë¤Î¤Ç¡¢$a ¤È $b ¤òÊѹ¹¤·¤Æ¤Ï¤¤¤±¤Ê¤¤¡£ Îã:
# ¼­½ñ½ç¤Ç¥½¡¼¥È
@articles = sort @files;

# ƱÍͤΤâ¤Î¤Ç¥½¡¼¥È¥ë¡¼¥Á¥ó¤òÌÀ¼¨¤·¤¿¤â¤Î
@articles = sort {$a cmp $b} @files;

# ƱÍͤΤâ¤Î¤ÇµÕ½ç
@articles = sort {$b cmp $a} @files;

# ¿ôÃÍŪ¤Ë¾º½ç¤Ë¥½¡¼¥È
@articles = sort {$a <=> $b} @files;

# ¿ôÃÍŪ¤Ë¹ß½ç¤Ë¥½¡¼¥È
@articles = sort {$b <=> $a} @files;

# ÌÀ¼¨Åª¤Ê¥µ¥Ö¥ë¡¼¥Á¥ó̾¤Ç¥½¡¼¥È
sub byage {
    $age{$a} <=> $age{$b}; # À°¿ô¤Ç¤¢¤ë¤È²¾Äꤷ¤Æ¤¤¤ë
}
@sortedclass = sort byage @class;

sub reverse { $b cmp $a; }
@harry = ('dog','cat','x','Cain','Abel');
@george = ('gone','chased','yz','Punished','Axed');
print sort @harry;
     # ½ÐÎÏ¤Ï AbelCaincatdogx
print sort reverse @harry;
     # ½ÐÎÏ¤Ï xdogcatCainAbel
print sort @george, 'to', @harry;
     # ½ÐÎÏ¤Ï AbelAxedCainPunishedcatchaseddoggonetoxyz

splice

`splice(ARRAY,OFFSET,LENGTH,LIST)'
`splice(ARRAY,OFFSET,LENGTH)'
`splice(ARRAY,OFFSET)'
ARRAY ¤«¤é OFFSET ¤È LENGTH ¤Ç¼¨¤µ¤ì¤¿Í×ÁǤò½ü¤­¡¢ LIST ¤¬¤¢¤ì¤Ð¤½¤ì¤ÈÆþ¤ìÂؤ¨¤ë¡£ÇÛÎ󤫤é½ü¤«¤ì¤¿Í×ÁǤòÊÖ¤¹¡£ ÇÛÎó¤ÏɬÍפ˱þ¤¸¤ÆÂ礭¤¯¤Ê¤Ã¤¿¤ê¾®¤µ¤¯¤Ê¤Ã¤¿¤ê¤¹¤ë¡£ LENGTH ¤ò¾Êά¤¹¤ë¤È¡¢OFFSET °Ê¹ß¤ÎÍ×ÁǤ¬Á´¤Æ½ü¤«¤ì¤ë¡£ ¼¡¤ÎÎã¤ÏÁ´¤Æ¤½¤ì¤¾¤ìƱÅù¤Ç¤¢¤ë¡£($[ == 0 ¤Ç¤¢¤ë¤È²¾Äꤷ¤Æ¤¤¤ë¡£)
push(@a,$x,$y)	        splice(@a,$#a+1,0,$x,$y)
pop(@a)                splice(@a,-1)
shift(@a)              splice(@a,0,1)
unshift(@a,$x,$y)      splice(@a,0,0,$x,$y)
$a[$x] = $y            splice(@a,$x,1,$y);
¼¡¤ÎÎã¤Ï¡¢ÇÛÎó¤ÎŤµ¤¬ÇÛÎó¤ÎÁ°¤ËÅϤµ¤ì¤ë¤È²¾Äꤷ¤Æ¤¤¤ë¡£
sub aeq { # 2 ¤Ä¤ÎÇÛÎóÃͤòÈæ³Ó¤¹¤ë
     local(@a) = splice(@_,0,shift);
     local(@b) = splice(@_,0,shift);
     return 0 unless @a == @b;     # Ʊ¤¸Ä¹¤µ?

     while (@a) {
         return 0 if pop(@a) ne pop(@b);
     }
     return 1;
}
if (&aeq($len,@foo[1..$len],0+@bar,@bar)) { ... }

split

`split(/PATTERN/,EXPR,LIMIT)'
`split(/PATTERN/,EXPR)'
`split(/PATTERN/)'
`split'
ʸ»úÎó¤òʸ»úÎó¤ÎÇÛÎó¤Ëʬ³ä¤·¡¢¤½¤ÎÇÛÎó¤òÊÖ¤¹¡£ (ÇÛÎó¤Î¥³¥ó¥Æ¥­¥¹¥È¤Ç¤Ê¤¤¾ì¹ç¤Ï¡¢¥Õ¥£¡¼¥ë¥É¤Î¿ô¤òÊÖ¤·¡¢ ʬ³ä¤Î·ë²Ì¤ò @_ ¤Ë³ÊǼ¤¹¤ë¡£ (ÇÛÎó¤Î¥³¥ó¥Æ¥­¥¹¥È¤Ç¤â¡¢¥Ñ¥¿¡¼¥ó delimiter ¤Ë ?? ¤ò»ØÄꤹ¤ë¤³¤È¤Ç @_ ¤Ø¤ÎÂåÆþ¤ò¶¯À©¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¤¬¡¢ ÊÖ¤êÃͤÏÇÛÎóÃͤΤޤޤǤ¢¤ë¡£)) EXPR ¤ò¾Êά¤¹¤ë¤È¡¢Ê¸»úÎó $_ ¤òʬ³ä¤¹¤ë¡£ PATTERN ¤â¾Êά¤¹¤ë¤È¡¢ whitespace (/[ \t\n]+/) ¤Çʬ³ä¤¹¤ë¡£ PATTERN ¤Ë¥Þ¥Ã¥Á¤¹¤ëʸ»ú¤Ï¡¢ Á´¤Æ¥Õ¥£¡¼¥ë¥É¤òʬ¤±¤ë delimiter ¤Ç¤¢¤ë¤È²ò¼á¤µ¤ì¤ë (Ãí°Õ: delimiter ¤Ï 1 »ú¤òĶ¤¨¤Æ¤â¤è¤¤)¡£ LIMIT ¤ò»ØÄꤹ¤ë¤È¡¢¤½¤ì¤òĶ¤¨¤Ê¤¤¿ô¤Ëʬ³ä¤¹¤ë(¾¯¤Ê¤¤¾ì¹ç¤â¤¢¤ë)¡£ LIMIT ¤ò»ØÄꤷ¤Ê¤¤¾ì¹ç¤Ï¡¢Í¾Ê¬¤Ê¥Ì¥ë¥Õ¥£¡¼¥ë¥É¤¬½ü¤«¤ì¤ë (pop() ¤ò»È¤ª¤¦¤È¤¤¤¦¥æ¡¼¥¶¤Ï¤³¤Î¤³¤È¤ò³Ð¤¨¤Æ¤ª¤¤¤¿Êý¤¬Îɤ¤¤Î¤Ç¤Ï?)¡£ ¥Ì¥ëʸ»úÎó¤Ë¥Þ¥Ã¥Á¤¹¤ë¥Ñ¥¿¡¼¥ó(¥Ì¥ë¥Ñ¥¿¡¼¥ó // ¤Èº®Æ±¤·¤Ê¤¤¤è¤¦¤Ë¡£ // ¤Ï¥Ì¥ëʸ»úÎó¤Ë¥Þ¥Ã¥Á¤¹¤ë¥Ñ¥¿¡¼¥ó·²¤Î°ì¤Ä¤Ë¤¹¤®¤Ê¤¤)¤Ï ¤½¤Î¥Ñ¥¿¡¼¥ó¤¬¥Þ¥Ã¥Á¤¹¤ëÁ´¤Æ¤ÎÅÀ¤Ç EXPR ¤ÎÃͤòʸ»ú¤Ëʬ³ä¤¹¤ë¡£
print join(':', split(/ */, 'hi there'));
¤Ï `h:i:t:h:e:r:e' ¤ò½ÐÎϤ¹¤ë¡£ LIMIT ¥Ñ¥é¥á¡¼¥¿¤Ï¹Ô¤Î°ìÉô¤òʬ³ä¤¹¤ë¤Î¤Ë»ÈÍѤǤ­¤ë¡£
($login, $passwd, $remainder) = split(/:/, $_, 3);
(¥ê¥¹¥È¤ËÂåÆþ¤¹¤ë»þ¤Ë LIMIT ¤¬¾Êά¤µ¤ì¤Æ¤¤¤ë¤È¡¢ perl ¤Ï¥ê¥¹¥ÈÃæ¤ÎÊÑ¿ô¤Î¿ô¤è¤ê 1 ¿¤¤¿ô¤ò LIMIT ¤È¤¹¤ë¡£ ¤³¤ì¤ÏÉÔɬÍפʺî¶È¤ò̵¤¯¤¹¤¿¤á¤Ç¤¢¤ë¡£ ¾å¤Î¥ê¥¹¥È¤Ç¤Ï¡¢LIMIT ¤Ï¥Ç¥Õ¥©¥ë¥È¤Ç 4 ¤Ç¤¢¤Ã¤¿¤Ï¤º¤Ç¤¢¤ë¡£ »þ´Ö¤Ë¥¯¥ê¥Æ¥£¥«¥ë¤Ê¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ç¤Ï ËÜÅö¤ËɬÍפʥե£¡¼¥ë¥É°Ê¾å¤Ëʬ³ä¤·¤Ê¤¤¤è¤¦¤Ë¤¹¤ë¤Ù¤­¤Ç¤¢¤ë¡£) PATTERN ¤¬³ç¸Ì¤ò´Þ¤ó¤Ç¤¤¤ë¾ì¹ç¡¢ delimiter Ãæ¤Ç¥Þ¥Ã¥Á¤¹¤ëʸ»úÎ󤫤餵¤é¤ËÇÛÎóÍ×ÁǤ¬ºî¤ê½Ð¤µ¤ì¤ë¡£
split(/([,-])/,"1-10,20");
¤¬ºî¤ëÇÛÎó¤ÎÃͤÏ
(1,'-',10,',',20)
/PATTERN/ ¤Ï¼Â¹Ô»þ¤ËÊѲ½¤¹¤ë¥Ñ¥¿¡¼¥ó¤ò»ØÄꤹ¤ë expression ¤Ç¤¢¤Ã¤Æ¤â¤è¤¤¡£ (¼Â¹Ô»þ¥³¥ó¥Ñ¥¤¥ë¤ò 1 ²ó¤À¤±¹Ô¤¦¤Ë¤Ï¡¢/$variable/o ¤òÍѤ¤¤ë¡£) Æüì¤Ê¾ì¹ç¤È¤·¤Æ¡¢¥¹¥Ú¡¼¥¹ (' ') ¤ò»ØÄꤹ¤ë¤È¡¢ ²¿¤â»ØÄꤷ¤Ê¤¤¾ì¹ç¤ÈƱ¤¸¤è¤¦¤Ë white space ¤Çʬ³ä¤¹¤ë¤¬¡¢ ʸ»úÎó¤Î»Ï¤á¤Ë whitespace ¤¬¤¢¤Ã¤Æ¤â°ìÈÖÌܤ˥̥ë¥Õ¥£¡¼¥ë¥É¤òºî¤é¤Ê¤¤¡£ ¤¹¤Ê¤ï¤Á¡¢ split(' ') ¤Ï awk ¤Î¥Ç¥Õ¥©¥ë¥È¤ÎÆ°ºî¤ò¥¨¥ß¥å¥ì¡¼¥È¤¹¤ë¤Î¤Ë»È¤¨¤ë¡£ ¤·¤«¤·¡¢ split(/ /) ¤Ïʸ»úÎó¤ÎºÇ½é¤Î¥¹¥Ú¡¼¥¹¤Î¿ô¤À¤±¥Ì¥ë¥Õ¥£¡¼¥ë¥É¤¬ÆÀ¤é¤ì¤ë¡£
open(passwd, '/etc/passwd');
while (<passwd>) {
     ($login, $passwd, $uid, $gid, $gcos, $home, $shell)
          = split(/:/);
     ...
}
Ãí°Õ: ¾å¤ÎÎã¤Ç $shell ¤Ï²þ¹Ôʸ»ú¤ò´Þ¤à¡£chop ¤ò»²¾È¡£
¤Þ¤¿¡¢join ¤â»²¾È¤Î¤³¤È¡£ See section chop, ¤ª¤è¤Ó See section join.

unshift

`unshift(ARRAY,LIST)'
»ëÅÀ¤Ë¤è¤ê¡¢shift ¤Þ¤¿¤Ï push ¤ÎµÕ¤ò¹Ô¤¦¡£ LIST ¤ò ARRAY ¤ÎÁ°¤ËÉÕ¤±¡¢¤Ç¤­¤¿ÇÛÎó¤ÎÍ×ÁÇ¿ô¤òÊÖ¤¹¡£
unshift(ARGV, '-e') unless $ARGV[0] =~ /^-/;
See section shift, ¤ª¤è¤Ó See section push.

values

`values(ASSOC_ARRAY)'
`values ASSOC_ARRAY'
»ØÄꤷ¤¿Ï¢ÁÛÇÛÎó¤ÎÁ´¤Æ¤ÎÃͤ«¤é¤Ê¤ëÄ̾ï¤ÎÇÛÎó¤òÊÖ¤¹¡£ ÃͤÏÁ´¤¯¥é¥ó¥À¥à¤Ê½ç½ø¤ÇÊ֤뤬¡¢ keys() ¤ä each() ´Ø¿ô¤¬Æ±¤¸ÇÛÎó¤ËÂФ·¤ÆÊÖ¤¹¤â¤Î¤ÈƱ¤¸½ç½ø¤Ç¤¢¤ë¡£ See section each, ¤ª¤è¤Ó See section keys.

¥Õ¥¡¥¤¥ëÁàºî´Ø¿ô

chmod

`chmod(LIST)'
`chmod LIST'
°À­¤ÏºÇ½é¤Î°ú¿ô¤Ë¤ª¤¤¤Æ¿ôÃͤǻØÄꤹ¤ë¡£ °À­¤òÊѹ¹¤¹¤ë¤Î¤ËÀ®¸ù¤·¤¿¥Õ¥¡¥¤¥ë¤Î¿ô¤òÊÖ¤¹¡£
$cnt = chmod 0755, 'foo', 'bar';
chmod 0755, @executables;

chown

`chown(LIST)'
`chown LIST'
uid ¤È gid ¤òºÇ½é¤Î°ú¿ôÆó¤Ä¤Ç(¤³¤Î½ç¤Ç)¿ôÃͤǻØÄꤹ¤ë¡£ Êѹ¹¤¹¤ë¤Î¤ËÀ®¸ù¤·¤¿¥Õ¥¡¥¤¥ë¤Î¿ô¤òÊÖ¤¹¡£
$cnt = chown $uid, $gid, 'foo', 'bar';
chown $uid, $gid, @filenames;

(Îã: passwd ¥Õ¥¡¥¤¥ë¤«¤é¿ôÃͤǤʤ¤ uid ¤ò¸¡º÷¤¹¤ë)
print "User: ";
$user = <STDIN>;
chop($user);
print "Files: "
$pattern = <STDIN>;
chop($pattern);
open(pass, '/etc/passwd')
     || die "Can't open passwd: $!\n";
while (<pass>) {
     ($login,$pass,$uid,$gid) = split(/:/);
     $uid{$login} = $uid;
     $gid{$login} = $gid;
}
@ary = <${pattern}>;     # ¥Õ¥¡¥¤¥ë̾¤òÆÀ¤ë
if ($uid{$user} eq ") {
     die "$user not in passwd file";
}
else {
     chown $uid{$user}, $gid{$user}, @ary;
}

link

`link(OLDFILE,NEWFILE)'
old filename ¤Ë¥ê¥ó¥¯¤µ¤ì¤¿ new filename ¤òºîÀ®¤¹¤ë¡£ À®¸ù¤Ê¤é 1¡¢¼ºÇԤʤé 0 ¤òÊÖ¤¹¡£

lstat

`lstat(FILEHANDLE)'
`lstat FILEHANDLE'
`lstat(EXPR)'
`lstat SCALARVARIABLE'
stat() ´Ø¿ô¤ÈƱ¤¸¤³¤È¤ò¤¹¤ë¤¬¡¢ ¥·¥ó¥Ü¥ê¥Ã¥¯¥ê¥ó¥¯¤¬»Ø¤¹¥Õ¥¡¥¤¥ë¤Ç¤Ï¤Ê¤¯¡¢ ¥·¥ó¥Ü¥ê¥Ã¥¯¥ê¥ó¥¯¤½¤Î¤â¤Î¤Î stat ¤òÊÖ¤¹¡£ ¥·¥ó¥Ü¥ê¥Ã¥¯¥ê¥ó¥¯¤ò¥¤¥ó¥×¥ê¥á¥ó¥È¤·¤Æ¤¤¤Ê¤¤¥·¥¹¥Æ¥à¤Ç¤Ï¡¢ stat ¤ÈƱ¤¸¤Ç¤¢¤ë¡£ See section stat.

mkdir

`mkdir(FILENAME,MODE)'
FILENAME ¤Ç»ØÄꤵ¤ì¤ë¥Ç¥£¥ì¥¯¥È¥ê¤òºîÀ®¤¹¤ë¡£ ¥Ñ¡¼¥ß¥Ã¥·¥ç¥ó¤Ï MODE(umask ¤Ç½¤¾þ¤µ¤ì¤ë)¤Ç»ØÄꤹ¤ë¡£ À®¸ù¤¹¤ì¤Ð 1 ¤òÊÖ¤·¡¢¼ºÇÔ¤¹¤ì¤Ð 0 ¤òÊÖ¤¹¤È¶¦¤Ë $! ¤ò¥»¥Ã¥È¤¹¤ë(errno)¡£

readlink

`readlink(EXPR)'
`readlink EXPR'
¥·¥ó¥Ü¥ê¥Ã¥¯¥ê¥ó¥¯¤¬¥¤¥ó¥×¥ê¥á¥ó¥È¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢ ¥·¥ó¥Ü¥ê¥Ã¥¯¥ê¥ó¥¯¤ÎÃͤòÊÖ¤¹¡£¤½¤¦¤Ç¤Ê¤¤¾ì¹ç¤ÏÃ×̿Ū¥¨¥é¡¼¤È¤Ê¤ë¡£ ¥·¥¹¥Æ¥à¥¨¥é¡¼¤¬µ¯¤³¤Ã¤¿¾ì¹ç¤Ï undefined value ¤òÊÖ¤·¡¢ $! ¤ò¥»¥Ã¥È¤¹¤ë(errno)¡£ EXPR ¤ò¾Êά¤¹¤ë¤È¡¢$_ ¤òÍѤ¤¤ë¡£

rename

`rename(OLDNAME,NEWNAME)'
¥Õ¥¡¥¤¥ë¤Î̾Á°¤òÊѹ¹¤¹¤ë¡£À®¸ù¤¹¤ì¤Ð 1¡¢¤½¤¦¤Ç¤Ê¤±¤ì¤Ð 0 ¤òÊÖ¤¹¡£ ¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤òĶ¤¨¤Æ¤ÏƯ¤«¤Ê¤¤¡£

rmdir

`rmdir(FILENAME)'
`rmdir FILENAME'
FILENAME ¤Ç»ØÄꤵ¤ì¤¿¥Ç¥£¥ì¥¯¥È¥ê¤¬¶õ¤Ê¤é¤Ð¾Ãµî¤¹¤ë¡£ À®¸ù¤¹¤ì¤Ð 1¡¢¤½¤¦¤Ç¤Ê¤±¤ì¤Ð 0 ¤òÊÖ¤·¡¢$!(errno) ¤ò¥»¥Ã¥È¤¹¤ë¡£ FILENAME ¤ò¾Êά¤¹¤ë¤È¡¢$_ ¤òÍѤ¤¤ë¡£

select

`select(FILEHANDLE)'
`select'
¸½ºß select ¤µ¤ì¤Æ¤¤¤ë¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤òÊÖ¤¹¡£ FILEHANDLE ¤ò»ØÄꤹ¤ì¤Ð½ÐÎϤΥǥե©¥ë¥È¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤ò¥»¥Ã¥È¤¹¤ë¡£ ¤³¤ì¤Ë¤ÏÆó¤Ä¤Î¸ú²Ì¤¬¤¢¤ë¡£ write ¤Þ¤¿¤Ï print ¤ò¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤Ê¤·¤ÇÍѤ¤¤ë¤È¡¢ ¥Ç¥Õ¥©¥ë¥È¤Î¤³¤Î FILEHANDLE ¤¬ÍѤ¤¤é¤ì¤ë¡£ ¤Þ¤¿¡¢½ÐÎϤ˴ØÏ¢¤Å¤±¤é¤ì¤¿ÊÑ¿ô¤Ø¤Î»²¾È¤Ï¡¢ ¤³¤Î(select ¤Ç»ØÄꤷ¤¿)½ÐÎÏ¥Á¥ã¥ó¥Í¥ë¤ò»²¾È¤¹¤ë¡£ Î㤨¤Ð¡¢ 1 °Ê¾å¤Î½ÐÎÏ¥Á¥ã¥ó¥Í¥ë¤Ë¤Ä¤¤¤Æ¥Õ¥©¡¼¥Þ¥Ã¥È¤ÎÀèƬ¹Ô¤ò¥»¥Ã¥È¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤»þ¤Ï¡¢
select(REPORT1);
$^ = 'report1_top';
select(REPORT2);
$^ = 'report2_top';
¤Î¤è¤¦¤Ë¤¹¤ì¤Ð¤è¤¤¡£ FILEHANDLE ¤Ï¼ÂºÝ¤Î¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤Î̾Á°¤òÃͤȤ·¤Æ»ý¤Ä expression¤Ç¤â¤è¤¤¡£ ¤·¤¿¤¬¤Ã¤Æ¡¢°Ê²¼¤Î¤è¤¦¤Ë»È¤¨¤ë¡£
$oldfh = select(STDERR); $| = 1; select($oldfh);
`select(RBITS,WBITS,EBITS,TIMEOUT)'
¥Ó¥Ã¥È¥Þ¥¹¥¯¤ò»ØÄꤷ¤Æ¥·¥¹¥Æ¥à¥³¡¼¥ë select ¤ò¥³¡¼¥ë¤¹¤ë¡£ ¥Ó¥Ã¥È¥Þ¥¹¥¯¤Ï fileno() ¤È vec() ¤òÍѤ¤¤Æ °Ê²¼¤Î¤è¤¦¤Ë¤·¤ÆÆÀ¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
$rin = $win = $ein = ";
vec($rin,fileno(STDIN),1) = 1;
vec($win,fileno(STDOUT),1) = 1;
$ein = $rin | $win;
¿¤¯¤Î¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤ò select ¤·¤¿¤¤»þ¤Ï ¥µ¥Ö¥ë¡¼¥Á¥ó¤ò½ñ¤¤¤¿Êý¤¬¤¤¤¤¤«¤â¤·¤ì¤Ê¤¤¡£
sub fhbits {
    local(@fhlist) = split(' ',$_[0]);
    local($bits);
    for (@fhlist) {
     vec($bits,fileno($_),1) = 1;
    }
    $bits;
}
$rin = &fhbits('STDIN TTY SOCK');
Ä̾ï¤Î»È¤¤Êý¤Ï¡¢
($nfound,$timeleft) =
  select($rout=$rin, $wout=$win, $eout=$ein, $timeout);
¤Þ¤¿¤Ï²¿¤«¤¬ ready ¤Ë¤Ê¤ë¤Þ¤Ç¥Ö¥í¥Ã¥¯¤¹¤ë¤Ë¤Ï¡¢
$nfound = select($rout=$rin, $wout=$win,
    $eout=$ein, undef);
¤Ç¤¢¤ë¡£ ¥Ó¥Ã¥È¥Þ¥¹¥¯¤Ï¤¤¤º¤ì¤â undef ¤Ë¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£ TIMEOUT ¤ò»ØÄꤹ¤ë»þ¤ÏÉÃñ°Ì¤Ç¡¢¾®¿ôÅÀ¤â²Äǽ¤Ç¤¢¤ë¡£ Ãí°Õ:
¥¤¥ó¥×¥ê¥á¥ó¥È¤Ë¤è¤Ã¤Æ¤Ï $timeleft ¤òÊÖ¤¹µ¡Ç½¤ÏÍøÍѤǤ­¤Ê¤¤¾ì¹ç¤¬¤¢¤ë¡£
¤½¤Î¾ì¹ç¤Ï¾ï¤Ë»ØÄꤷ¤¿ $timeout ¤ÈƱ¤¸ÃÍ¤Ç $timeleft ¤¬Ê֤롣

stat

`stat(FILEHANDLE)'
`stat FILEHANDLE'
`stat(EXPR)'
`stat SCALARVARIABLE'
FILEHANDLE ¤Ç¥ª¡¼¥×¥ó¤µ¤ì¤Æ¤¤¤ë¤«¡¢ ¥Õ¥¡¥¤¥ë¥Í¡¼¥à¤¬ EXPR ¤Ç¤¢¤ë ¥Õ¥¡¥¤¥ë¤Î statistics ¤òɽ¤¹ 13 Í×ÁǤÎÇÛÎó¤òÊÖ¤¹¡£ stat ¤¬¼ºÇÔ¤·¤¿¾ì¹ç¤Ï¥Ì¥ë¥ê¥¹¥È¤òÊÖ¤¹¡£ ŵ·¿Åª¤Ë¤Ï°Ê²¼¤Î¤è¤¦¤Ë»ÈÍѤ¹¤ë¡£
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
   $atime,$mtime,$ctime,$blksize,$blocks)
       = stat($filename);
stat ¤ËÆüì¤Ê¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤È¤·¤Æ¥¢¥ó¥À¡¼¥é¥¤¥ó¤ò»ØÄꤹ¤ë¤È¡¢ stat ¤ò¹Ô¤ï¤º¡¢ ºÇ¸å¤Î stat ¤Þ¤¿¤Ï ¥Õ¥¡¥¤¥ë¥Æ¥¹¥È¤Î·ë²Ì¤Ç¤¢¤ë stat ¹½Â¤ÂΤÎÆâÍƤòÊÖ¤¹¡£
if (-x $file && (($d) = stat(_)) && $d < 0) {
     print "$file is executable NFS file\n";
}
(¤³¤ÎÎã¤Ï NFS ¤Î¥Ç¥Ð¥¤¥¹Èֹ椬Éé¤Ë¤Ê¤ë¤è¤¦¤Ê¥Þ¥·¥ó¤Ç¤Î¤ßÆ°ºî¤¹¤ë¡£)

symlink

`symlink(OLDFILE,NEWFILE)'
OLDFILE ¤Ë¥·¥ó¥Ü¥ê¥Ã¥¯¥ê¥ó¥¯¤µ¤ì¤¿ NEWFILE ¤òºîÀ®¤¹¤ë¡£ À®¸ù¤¹¤ì¤Ð 1¡¢¤½¤ì°Ê³°¤Ç¤Ï 0 ¤òÊÖ¤¹¡£ ¥·¥ó¥Ü¥ê¥Ã¥¯¥ê¥ó¥¯¤ò¥µ¥Ý¡¼¥È¤·¤Ê¤¤¥·¥¹¥Æ¥à¤Ç¤Ï¡¢¼Â¹Ô»þ¤ËÃ×̿Ū¥¨¥é¡¼¤È¤Ê¤ë¡£ ¤½¤ì¤ò¥Á¥§¥Ã¥¯¤¹¤ë¤Ë¤Ï¡¢eval ¤òÍѤ¤¤ë¡£
$symlink_exists = (eval	'symlink("","");', $@ eq ");

truncate

`truncate(FILEHANDLE,LENGTH)'
`truncate(EXPR,LENGTH)'
FILEHANDLE ¤Ë¥ª¡¼¥×¥ó¤µ¤ì¤¿¥Õ¥¡¥¤¥ë ¤Þ¤¿¤Ï EXPR ¤È¤¤¤¦Ì¾Á°¤Î¥Õ¥¡¥¤¥ë¤ò»ØÄꤹ¤ëŤµ¤ËÀÚ¤êµÍ¤á¤ë¡£ ¥·¥¹¥Æ¥à¤Ë truncate ¤¬¥¤¥ó¥×¥ê¥á¥ó¥È¤µ¤ì¤Æ¤¤¤Ê¤±¤ì¤ÐÃ×̿Ū¥¨¥é¡¼¤È¤Ê¤ë¡£

unlink

`unlink(LIST)'
`unlink LIST'
¥ê¥¹¥È¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¤ò¾Ãµî¤¹¤ë¡£¾Ãµî¤ËÀ®¸ù¤·¤¿¥Õ¥¡¥¤¥ë¤Î¿ô¤òÊÖ¤¹¡£
$cnt = unlink 'a', 'b', 'c';
unlink @goners;
unlink <*.bak>;
Ãí°Õ: unlink ¤Ï¥¹¡¼¥Ñ¡¼¥æ¡¼¥¶¤Ç¤¢¤Ã¤Æ ¤«¤Ä perl ¤Ë -U ¥Õ¥é¥°¤ò»ØÄꤷ¤Æ¤¤¤Ê¤¤¤«¤®¤ê¥Ç¥£¥ì¥¯¥È¥ê¤Ï¾Ãµî¤·¤Ê¤¤¡£ ¤³¤ì¤é¤Î¾ò·ï¤Ë¤¢¤Æ¤Ï¤Þ¤Ã¤Æ¤¤¤ë¾ì¹ç¤Ç¤â¡¢ ¥Ç¥£¥ì¥¯¥È¥ê¤ò unlink ¤¹¤ë¤³¤È¤Ï ¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤Ë¥À¥á¡¼¥¸¤òÍ¿¤¨¤ë¤³¤È¤ËÃí°Õ¤»¤è¡£ ¤«¤ï¤ê¤Ë rmdir ¤ò»È¤¦¤³¤È¡£

utime

`utime(LIST)'
`utime LIST'
¥ê¥¹¥È¤·¤¿¥Õ¥¡¥¤¥ë¤ÎÁ´¤Æ¤Ë¤Ä¤¤¤Æ¥¢¥¯¥»¥¹»þ¹ï¤ÈÊѹ¹»þ¹ï¤òÊѹ¹¤¹¤ë¡£ ¥ê¥¹¥È¤ÎºÇ½é¤Î 2 Í×ÁǤϿôÃͤǤʤ¯¤Æ¤Ï¤Ê¤é¤º¡¢¥¢¥¯¥»¥¹»þ¹ï¡¢Êѹ¹»þ¹ï¤Î½ç¤Ç¤¢¤ë¡£ Êѹ¹¤ËÀ®¸ù¤·¤¿¥Õ¥¡¥¤¥ë¤Î¿ô¤òÊÖ¤¹¡£ ³Æ¥Õ¥¡¥¤¥ë¤Î inode ¤ÎÊѹ¹»þ¹ï¤Ï¸½ºß»þ¹ï¤Ë¥»¥Ã¥È¤µ¤ì¤ë¡£ `touch' ¥³¥Þ¥ó¥É¤ÎÎã:
#!/usr/bin/perl
$now = time;
utime $now, $now, @ARGV;

¥Ç¥£¥ì¥¯¥È¥êÆɤ߹þ¤ß´Ø¿ô

closedir

`closedir(DIRHANDLE)'
`closedir DIRHANDLE'
opendir() ¤Ç open ¤µ¤ì¤¿¥Ç¥£¥ì¥¯¥È¥ê¤ò close ¤¹¤ë¡£

opendir

`opendir(DIRHANDLE,EXPR)'
EXPR ¤È¤¤¤¦Ì¾Á°¤Î¥Ç¥£¥ì¥¯¥È¥ê¤ò open ¤·¡¢ readdir()¡¢telldir()¡¢seekdir()¡¢
rewinddir()¡¢closedir() ¤ò²Äǽ¤Ë¤¹¤ë¡£ À®¸ù¤¹¤ì¤Ð true ¤òÊÖ¤¹¡£
¥Ç¥£¥ì¥¯¥È¥ê¥Ï¥ó¥É¥ë¤Ë¤Ï¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤È¤ÏÊ̤Î̾Á°¶õ´Ö¤¬¤¢¤ë¡£

readdir

`readdir(DIRHANDLE)'
`readdir DIRHANDLE'
opendir() ¤Ç¥ª¡¼¥×¥ó¤·¤¿¥Ç¥£¥ì¥¯¥È¥ê¤Î¼¡¤Î¥¨¥ó¥È¥ê¤òÊÖ¤¹¡£ ÇÛÎó¤Î¥³¥ó¥Æ¥­¥¹¥È¤ÇÍѤ¤¤ë¤È¡¢¥Ç¥£¥ì¥¯¥È¥ê¤Î»Ä¤ê¤Î¥¨¥ó¥È¥ê¤òÁ´¤ÆÊÖ¤¹¡£ ¥¨¥ó¥È¥ê¤¬»Ä¤Ã¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¡¢¥¹¥«¥é¡¼¤Î¥³¥ó¥Æ¥­¥¹¥È¤Ç¤Ï undefined value¡¢ ÇÛÎó¤Î¥³¥ó¥Æ¥­¥¹¥È¤Ç¤Ï¥Ì¥ë¥ê¥¹¥È¤òÊÖ¤¹¡£

rewinddir

`rewinddir(DIRHANDLE)'
`rewinddir DIRHANDLE'
readdir() ¤ÇÍѤ¤¤ë¡¢ DIRHANDLE ¤Î¥«¥ì¥ó¥È°ÌÃÖ¤ò¥Ç¥£¥ì¥¯¥È¥ê¤ÎºÇ½é¤Ë¥»¥Ã¥È¤¹¤ë¡£

seekdir

`seekdir(DIRHANDLE,POS)'
readdir() ¤ÇÍѤ¤¤ë DIRHANDLE ¤Î¥«¥ì¥ó¥È°ÌÃÖ¤ò¥»¥Ã¥È¤¹¤ë¡£ POS ¤Ïtelldir() ¤¬ÊÖ¤¹ÃͤǤʤ¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£ directory compaction ¤Ë¤Ä¤¤¤Æ¤Ï Âбþ¤¹¤ë¥·¥¹¥Æ¥à¥é¥¤¥Ö¥é¥ê´Ø¿ô¤ÈƱÍͤÎÃí°Õ¤¬É¬ÍפǤ¢¤ë¡£

telldir

`telldir(DIRHANDLE)'
`telldir DIRHANDLE'
DIRHANDLE ¤ËÂФ¹¤ë readdir() ¤Î¸½ºß¤Î°ÌÃÖ¤òÊÖ¤¹¡£ ¥Ç¥£¥ì¥¯¥È¥ê¤Î¤¢¤ë°ÌÃ֤˥¢¥¯¥»¥¹¤¹¤ë¤¿¤á¤Ë ¤³¤ÎÃͤò seekdir() ¤Ë»ØÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤ë¡£ directory compaction ¤Ë¤Ä¤¤¤Æ¤Ï Âбþ¤¹¤ë¥·¥¹¥Æ¥à¥é¥¤¥Ö¥é¥ê¥ë¡¼¥Á¥ó¤ÈƱ¤¸Ãí°Õ¤¬É¬ÍפǤ¢¤ë¡£

Æþ½ÐÎÏ´Ø¿ô

°Ê²¼¤Î¹àÌܤÎÀâÌÀ¤Ë¤ª¤±¤ë FILEHANDLE ¤Ï¡¢ open ¤Ç¥ª¡¼¥×¥ó¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤«¡¢ ¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤Î̾Á°¤òÃͤ˻ý¤Ä¥¹¥«¥é¡¼ÊÑ¿ô¤Ç¤¢¤ë¡£

binmode

`binmode(FILEHANDLE)'
`binmode FILEHANDLE'
¥Ð¥¤¥Ê¥ê¥Õ¥¡¥¤¥ë¤È¥Æ¥­¥¹¥È¥Õ¥¡¥¤¥ë¤ò¶èÊ̤¹¤ë OS ¤Ë¤ª¤¤¤Æ¡¢ ¥Õ¥¡¥¤¥ë¤ò¥Ð¥¤¥Ê¥ê¥â¡¼¥É¤ÇÆɤà¤è¤¦¤Ë¤¹¤ë¡£ ¥Ð¥¤¥Ê¥ê¥â¡¼¥É¤Ç¤Ê¤¤¾ì¹ç¤ÏÆþÎÏ¤ÎºÝ¤Ë CR LF ¤¬ LF ¤Ë¡¢ ½ÐÎÏ¤ÎºÝ¤Ë LF ¤¬ CR LF ¤ËÊÑ´¹¤µ¤ì¤ë¡£ Unix ¤Î²¼¤Ç¤Ï²¿¤Î¸ú²Ì¤â¤Ê¤¤¡£ FILEHANDLE ¤¬ expression ¤Î¾ì¹ç¤Ï¡¢ ¤½¤ÎÃͤ¬¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤Î̾Á°¤È¤·¤Æ²ò¼á¤µ¤ì¤ë¡£

close

`close(FILEHANDLE)'
`close FILEHANDLE'
¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤Ë·ë¤ÓÉÕ¤±¤é¤ì¤Æ¤¤¤ë¥Õ¥¡¥¤¥ë¤ä¥Ñ¥¤¥×¤ò¥¯¥í¡¼¥º¤¹¤ë¡£ Ʊ¤¸ FILEHANDLE ¤òÍѤ¤¤Æ¤¹¤°¤Ë¤Þ¤¿ open ¤¹¤ë¾ì¹ç¤Ï¡¢ close ¤¹¤ëɬÍפÏ̵¤¤¤¬(open ¤¬ close ¤¹¤ë)¡¢ ÆþÎÏ¥Õ¥¡¥¤¥ë¤ËÂФ·¤ÆÌÀ¼¨Åª¤Ë close ¤ò¹Ô¤¦¤È ¥é¥¤¥ó¥«¥¦¥ó¥¿($.)¤¬¥ê¥»¥Ã¥È¤µ¤ì¤ë (open ¤Î¹Ô¤¦ close ¤Ç¤Ï¤½¤¦¤Ê¤é¤Ê¤¤)¡£See section @hbox{@hbox to 1.6em{@tt@$.@hfil} : ºÇ¸å¤ËÆɤ߹þ¤ß¤ò¹Ô¤Ã¤¿¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤Î¸½ºß¤Î¹ÔÈÖ¹æ}. ¤Þ¤¿¡¢¥Ñ¥¤¥×¤ò close ¤¹¤ë»þ¤Ë¤Ï ¤½¤Î¥Ñ¥¤¥×¤òÍѤ¤¤Æ¼Â¹Ô¤µ¤ì¤Æ¤¤¤ë¥×¥í¥»¥¹¤¬½ª¤ï¤ë¤Î¤òÂÔ¤Ä (¤¢¤È¤Ç¥Ñ¥¤¥×¤Î½ÐÎϤò¸«¤ë¤³¤È¤¬¤Ç¤­¤ë¤è¤¦¤Ë)¡£ ¥Ñ¥¤¥×¤òÌÀ¼¨Åª¤Ë close ¤¹¤ë¤È¥³¥Þ¥ó¥É¤Î¥¹¥Æ¡¼¥¿¥¹¤¬ $? ¤ËÆþ¤ë¡£
open(OUTPUT, '|sort >foo');   # pipe to sort
...  # print stuff to output
close OUTPUT;       # wait for sort to finish
open(INPUT, 'foo'); # get sort's results
FILEHANDLE ¤Ï¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤Î̾Á°¤òÃͤȤ·¤Æ»ý¤Ä expression ¤Ç¤â¤¤¤¤¡£

dbmclose

`dbmclose(ASSOC_ARRAY)'
`dbmclose ASSOC_ARRAY'
dbm ¥Õ¥¡¥¤¥ë¤ÈÏ¢ÁÛÇÛÎó¤Î bind ¤ò½ªÎ»¤¹¤ë¡£ Ï¢ÁÛÇÛÎó¤Ë»Ä¤Ã¤Æ¤¤¤ëÃͤϰÕÌ£¤¬¤Ê¤¤¡£ ¤³¤Î´Ø¿ô¤Ï ndbm ¤¬¤¢¤ë¾ì¹ç¤Ë¤Î¤ßÊØÍø¤Ç¤¢¤ë¡£

dbmopen

`dbmopen(ASSOC,DBNAME,MODE)'
dbm ¤Þ¤¿¤Ï ndbm ¥Õ¥¡¥¤¥ë¤ÈÏ¢ÁÛÇÛÎó¤ò bind ¤¹¤ë¡£ ASSOC ¤ÏÏ¢ÁÛÇÛÎó¤Î̾Á°¤Ç¤¢¤ë(»÷¤Æ¤Ï¤¤¤ë¤±¤ì¤É¡¢ ÉáÄ̤Πopen ¤È°ã¤¤¡¢ºÇ½é¤Î°ú¿ô¤Ï¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤Ç¤Ï¤Ê¤¤)¡£ DBNAME ¤Ï¥Ç¡¼¥¿¥Ù¡¼¥¹¤Î̾Á°¤«¤é `.dir'¤Þ¤¿¤Ï `.pag' ¤Î³ÈÄ¥»Ò¤ò¤È¤Ã¤¿¤â¤Î¤Ç¤¢¤ë¡£ ¥Ç¡¼¥¿¥Ù¡¼¥¹¤¬Â¸ºß¤·¤Ê¤±¤ì¤Ð¡¢ MODE ¤Ç»ØÄꤵ¤ì¤ëÊݸî¥â¡¼¥É¤ÇºîÀ®¤µ¤ì¤ë¡£ ¸Å¤¤ dbm ´Ø¿ô¤·¤«¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Ê¤¤¥·¥¹¥Æ¥à¤Î¾ì¹ç¤Ï¡¢ ¥×¥í¥°¥é¥àÃæ¤Ç dbmopen ¤Ï°ì²ó¤·¤«¼Â¹Ô¤¹¤ë¤³¤È¤¬¤Ç¤­¤Ê¤¤¡£ dbm ¤â ndbm ¤â¤Ê¤¤¥·¥¹¥Æ¥à¤Ç dbmopen ¤ò¥³¡¼¥ë¤¹¤ë¤È Ã×̿Ū¥¨¥é¡¼¤È¤Ê¤ë¡£ dbmopen ¤ÎÁ°¤ÎÏ¢ÁÛÇÛÎó¤ÎÃͤϼº¤ï¤ì¤ë¡£ dbm ¥Õ¥¡¥¤¥ë¤ÎÃͤΰìÉô¤Ï¥á¥â¥ê¤Ë¥­¥ã¥Ã¥·¥å¤µ¤ì¤ë¡£ ¤³¤ì¤Ï¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï 64 ¸Ä¤Ç¤¢¤ë¤¬¡¢ dbmopen ¤ËÀèΩ¤Ã¤ÆÏ¢ÁÛÇÛÎó¤Ë¥À¥ß¡¼¤ÎÃͤòÂåÆþ¤¹¤ë¤³¤È¤ÇÁý¤ä¤¹¤³¤È¤¬¤Ç¤­¤ë¡£ ɬÍפʤ顢reset ¥³¥Þ¥ó¥É¤Ç¥­¥ã¥Ã¥·¥å¤ò¥Õ¥é¥Ã¥·¥å¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£ dbm ¥Õ¥¡¥¤¥ë¤Ë½ñ¤­¹þ¤ßµö²Ä¤¬¤Ê¤¤¾ì¹ç¡¢ Ï¢ÁÛÇÛÎó¤ÎÃͤòÆɤळ¤È¤Ï¤Ç¤­¤Æ¤â¡¢ÂåÆþ¤Ï¤Ç¤­¤Ê¤¤¡£ ½ñ¤­¹þ¤ß¤¬¤Ç¤­¤ë¤«¤É¤¦¤«¥Æ¥¹¥È¤¹¤ë¤Î¤Ê¤é¡¢¥Õ¥¡¥¤¥ë¥Æ¥¹¥È¤ò»È¤¦¤«¡¢ eval Ãæ¤Ç¥À¥ß¡¼¤ÎÇÛÎó¤ò¥»¥Ã¥È¤·¤Æ¤ß¤Æ¡¢ ¥¨¥é¡¼¤¬µ¯¤³¤ë¤«¤É¤¦¤«¤ÇȽÃǤ¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£ Â礭¤Ê dbm ¥Õ¥¡¥¤¥ë¤Î¾ì¹ç¡¢ keys() ¤ä values() ¤È¤¤¤Ã¤¿´Ø¿ô¤ÏµðÂç¤ÊÇÛÎó¤òÊÖ¤¹¤³¤È¤¬¤¢¤ë¡£ each() ¤òÍѤ¤¤Æ Â礭¤Ê dbm ¥Õ¥¡¥¤¥ë¤Ë¤Ä¤¤¤Æ·«¤êÊÖ¤·¤ò¹Ô¤¤¤¿¤¤¾ì¹ç¤Ï¡¢¼¡¤ÎÎã¤ò»²¾È¡£
# ¥Ò¥¹¥È¥ê¡¼¥Õ¥¡¥¤¥ë¤Î¥ª¥Õ¥»¥Ã¥È¤ò½ÐÎÏ
dbmopen(HIST,'/usr/lib/news/history',0666);
while (($key,$val) = each %HIST) {
     print $key, ' = ', unpack('L',$val), "\n";
}
dbmclose(HIST);

eof

`eof(FILEHANDLE)'
`eof()'
`eof'
FILEHANDLE ¤ËÂФ¹¤ë¼¡¤ÎÆɤ߹þ¤ß¤¬ end of file ¤òÊÖ¤¹¤«¡¢ FILEHANDLE ¤¬ open ¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢1 ¤òÊÖ¤¹¡£ FILEHANDLE ¤Ï ¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤Î̾Á°¤òÃͤ˻ý¤Ä expression ¤Ç¤â¤è¤¤¡£ (Ãí°Õ: ¤³¤Î´Ø¿ô¤Ï¼ÂºÝ¤Ë¤Ï 1 ʸ»úÆɤ߹þ¤ó¤Ç¤½¤ì¤ò ungetc ¤¹¤ë¤Î¤Ç¡¢ ¥¤¥ó¥¿¥é¥¯¥Æ¥£¥Ö¤Ê¥³¥ó¥Æ¥­¥¹¥È¤Ç¤Ï¤¢¤Þ¤êÍ­ÍѤǤϤʤ¤¡£) °ú¿ô¤Ê¤·¤Î eof ¤ÏºÇ¸å¤ËÆɤ߹þ¤ó¤À¥Õ¥¡¥¤¥ë¤Î eof ¥¹¥Æ¡¼¥¿¥¹¤òÊÖ¤¹¡£ ¶õ¤Î³ç¸Ì () ¤Ï¡¢¥³¥Þ¥ó¥É¥é¥¤¥ó¤Ç»ØÄꤵ¤ì¤¿¥Õ¥¡¥¤¥ë¤«¤éºî¤é¤ì¤ë µ¼»÷¥Õ¥¡¥¤¥ë¤ò»ØÄꤹ¤ë¤Î¤Ë»È¤ï¤ì¤ë¡£ ¨¤Á¡¢eof() ¤Ï while (<>) ¤ÎÃæ¤Ç ºÇ¸å¤Î¥Õ¥¡¥¤¥ë¤Î½ª¤ï¤ê¤ò¸¡½Ð¤¹¤ë¤¿¤á¤Ë»È¤¦»þ¤Î¤ß°ÕÌ£¤¬¤¢¤ë¡£ while (<>) ¥ë¡¼¥×¤ÎÁ´¤Æ¤Î¥Õ¥¡¥¤¥ë¤Î½ª¤ï¤ê¸¡½Ð¤Î¤¿¤á¤Ë¤Ï¡¢ eof(ARGV) ¤« ³ç¸Ì¤Î¤Ê¤¤ eof ¤ò»È¤¦¤Ù¤­¤Ç¤¢¤ë¡£
# ºÇ¸å¤Î¥Õ¥¡¥¤¥ë¤ÎºÇ¸å¤Î 1 ¹ÔÁ°¤Ë¥À¥Ã¥·¥å¤òÆþ¤ì¤ë
while (<>) {
     if (eof()) {
          print "--------------\n";
     }
     print;
}

# ³ÆÆþÎÏ¥Õ¥¡¥¤¥ë¤´¤È¤Ë¹ÔÈÖ¹æ¤ò¥ê¥»¥Ã¥È¤¹¤ë
while (<>) {
     print "$.\t$_";
     if (eof) {     # eof() ¤Ç¤Ï¤Ê¤¤¡£
          close(ARGV);
     }
}

fcntl

`fcntl(FILEHANDLE,FUNCTION,SCALAR)'
fcntl(2) ´Ø¿ô¤ò¥¤¥ó¥×¥ê¥á¥ó¥È¤¹¤ë¡£Àµ¤·¤¯´Ø¿ô¤òÄêµÁ¤¹¤ë¤Ë¤Ï¤ª¤½¤é¤¯
require "fcntl.ph";  # ¤¿¤Ö¤ó /usr/local/lib/perl/fcntl.ph
¤òºÇ½é¤Ë¹Ô¤¦É¬Íפ¬¤¢¤ë¤À¤í¤¦¡£ `fcntl.ph' ¤¬¤Ê¤«¤Ã¤¿¤êÀµ¤·¤¯ÄêµÁ¤µ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢
`<sys/fcntl.h>' ¤Ê¤É¤Ë´ð¤Å¤¤¤Æ¼«Ê¬¤ÇÄêµÁ¤¹¤ëɬÍפ¬¤¢¤ë¡£ (perl ¥­¥Ã¥È¤Ë¤Ï¤³¤Îºî¶È¤ò½õ¤±¤ë¤¿¤á¤Î `h2ph' ¤È¤¤¤¦ perl ¥¹¥¯¥ê¥×¥È¤¬¤¢¤ë¡£) °ú¿ô¤Î½èÍý¤äÊÖ¤êÃÍ¤Ï ioctl ¤ÈÁ´¤¯Æ±¤¸¤Ç¤¢¤ë¡£ Ãí°Õ: fcntl(2) ¤ò¥¤¥ó¥×¥ê¥á¥ó¥È¤·¤Æ¤¤¤Ê¤¤¥Þ¥·¥ó¤Ç»ÈÍѤ¹¤ë¤È Ã×̿Ū¥¨¥é¡¼¤È¤Ê¤ë¡£

fileno

`fileno(FILEHANDLE)'
`fileno FILEHANDLE'
¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤ËÂФ¹¤ë¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤òÊÖ¤¹¡£ select() ¤Î¥Ó¥Ã¥È¥Þ¥Ã¥×¤ò¹½ÃÛ¤¹¤ë¤Î¤ËÊØÍø¤Ç¤¢¤ë¡£ FILEHANDLE ¤¬ expression ¤Î¾ì¹ç¤Ï¡¢ ¤½¤ÎÃͤ¬¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤Î̾Á°¤Ç¤¢¤ë¤È²ò¼á¤µ¤ì¤ë¡£

flock

`flock(FILEHANDLE,OPERATION)'
FILEHANDLE ¤Ë¤Ä¤¤¤Æ flock(2) ¤ò¥³¡¼¥ë¤¹¤ë¡£ OPERATION ¤ÎÄêµÁ¤Ë¤Ä¤¤¤Æ¤Ï flock(2) ¤Î¥Þ¥Ë¥å¥¢¥ë¤ò»²¾È¤Î¤³¤È¡£ À®¸ù¤¹¤ë¤È true¡¢¼ºÇÔ¤¹¤ë¤È false ¤òÊÖ¤¹¡£ flock(2) ¤ò¥¤¥ó¥×¥ê¥á¥ó¥È¤·¤Æ¤¤¤Ê¤¤¥Þ¥·¥ó¤Ç»ÈÍѤ¹¤ë¤È Ã×̿Ū¥¨¥é¡¼¤È¤Ê¤ë¡£°Ê²¼¤Ï BSD ¥·¥¹¥Æ¥àÍÑ mailbox appender ¤Ç¤¢¤ë¡£
$LOCK_SH = 1;
$LOCK_EX = 2;
$LOCK_NB = 4;
$LOCK_UN = 8;

sub lock {
    flock(MBOX,$LOCK_EX);
    # ¤½¤·¤Æ¡¢ÂԤäƤ¤¤ë´Ö¤Ë狼¤¬Äɲ乤ë¾ì¹ç¤ËÈ÷¤¨¤Æ...
    seek(MBOX, 0, 2);
}

sub unlock {
    flock(MBOX,$LOCK_UN);
}

open(MBOX, ">>/usr/spool/mail/$ENV{'USER'}")
     || die "Can't open mailbox: $!";

do lock();
print MBOX $msg,"\n\n";
do unlock();

getc

`getc(FILEHANDLE)'
`getc FILEHANDLE'
`getc'
FILEHANDLE ¤Ë·ë¤ÓÉÕ¤¤¤Æ¤¤¤ëÆþÎÏ¥Õ¥¡¥¤¥ë¤Î¼¡¤Îʸ»ú¤òÊÖ¤¹¡£ EOF ¤Î¾ì¹ç¤Ï¥Ì¥ëʸ»úÎó¤òÊÖ¤¹¡£ FILEHANDLE ¤ò¾Êά¤¹¤ë¤È¡¢STDIN ¤«¤éÆɤࡣ

ioctl

`ioctl(FILEHANDLE,FUNCTION,SCALAR)'
ioctl(2) ´Ø¿ô¤ò¥¤¥ó¥×¥ê¥á¥ó¥È¤¹¤ë¡£Àµ¤·¤¯´Ø¿ô¤òÄêµÁ¤¹¤ë¤Ë¤Ï¤ª¤½¤é¤¯
require "ioctl.ph";  # probably /usr/local/lib/perl/ioctl.ph
¤òºÇ½é¤Ë¹Ô¤¦É¬Íפ¬¤¢¤ë¤À¤í¤¦¡£ `ioctl.ph' ¤¬¤Ê¤«¤Ã¤¿¤êÀµ¤·¤¯ÄêµÁ¤µ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢
`<sys/ioctl.h>' ¤Ê¤É¤Ë´ð¤Å¤¤¤Æ¼«Ê¬¤ÇÄêµÁ¤¹¤ëɬÍפ¬¤¢¤ë¡£ (perl ¥­¥Ã¥È¤Ë¤Ï¡¢ ¤³¤Îºî¶È¤ò½õ¤±¤ë¤¿¤á¤Î `h2ph' ¤È¤¤¤¦ perl ¥¹¥¯¥ê¥×¥È¤¬¤¢¤ë¡£) SCALAR ¤Ï FUNCTION ¤Ë¤è¤ê¡¢ »²¾È¤«¤Ä¤Þ¤¿¤ÏÂåÆþ¤µ¤ì¤ë -- SCALAR ¤Îʸ»úÎóÃͤؤΥݥ¤¥ó¥¿¤¬ ¼ÂºÝ¤Î ioctl ¥³¡¼¥ë¤Î»°ÈÖÌܤΰú¿ô¤È¤·¤ÆÅϤµ¤ì¤ë¡£ (SCALAR ¤¬Ê¸»úÎóÃͤǤʤ¯¤Æ¿ôÃͤξì¹ç¤Ï¡¢ ʸ»úÎóÃͤؤΥݥ¤¥ó¥¿¤Ç¤Ï¤Ê¤¯¤½¤ÎÃͤ¬ÅϤµ¤ì¤ë¡£ ¤³¤ì¤ò¾ï¤ËÊݾڤ¹¤ë¤Ë¤Ï¡¢SCALAR ¤Ë¤¢¤é¤«¤¸¤á 0 ¤ò­¤»¤ÐÎɤ¤¡£) ioctl() ¤Ç»ÈÍѤµ¤ì¤ë¹½Â¤ÂΤÎÃͤòÁàºî¤¹¤ë¤Ë¤Ï¡¢ pack() ¤ä unpack() ´Ø¿ô¤¬ÊØÍø¤Ç¤¢¤ë¡£ ¼¡¤ÎÎã¤Ç¤Ï¡¢erase character ¤ò DEL ¤Ë¥»¥Ã¥È¤¹¤ë¡£
do 'ioctl.ph';
$sgttyb_t = "ccccs";          # char 4 ¤Ä¤È short
if (ioctl(STDIN,$TIOCGETP,$sgttyb)) {
     @ary = unpack($sgttyb_t,$sgttyb);
     $ary[2] = 127;
     $sgttyb = pack($sgttyb_t,@ary);
     ioctl(STDIN,$TIOCSETP,$sgttyb)
          || die "Can't ioctl: $!";
}
ioctl(¤ª¤è¤Ó fcntl)¤ÎÊÖ¤êÃͤϼ¡¤Î¤è¤¦¤Ë¤Ê¤ë¡£
OS ¤ÎÊÖ¤êÃÍ:            perl ¤ÎÊÖ¤êÃÍ
    -1                  undefined value
    0                   string `0 but true'
    ¤½¤ì°Ê³°             ¤½¤ÎÃÍ
¤Ä¤Þ¤ê¡¢perl ¤ÏÀ®¸ù¤¹¤ì¤Ð¿¿¡¢¼ºÇÔ¤¹¤ì¤Ðµ¶¤òÊÖ¤¹¤¬¡¢ OS ¤¬ÊÖ¤¹¼ÂºÝ¤ÎÃͤò´Êñ¤ËÆÀ¤ë¤³¤È¤â¤Ç¤­¤ë¡£
($retval = ioctl(...)) || ($retval = -1);
printf "System returned %d\n", $retval;

open

`open(FILEHANDLE,EXPR)'
`open(FILEHANDLE)'
`open FILEHANDLE'
¥Õ¥¡¥¤¥ë̾¤¬ EXPR ¤Ç»ØÄꤵ¤ì¤ë¥Õ¥¡¥¤¥ë¤ò open ¤·¡¢ FILEHANDLE ¤È·ë¤ÓÉÕ¤±¤ë¡£ FILEHANDLE ¤¬ expression ¤Î¾ì¹ç¤Ï¡¢ ¤½¤ÎÃͤ¬¼ÂºÝ¤Î¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤Î̾Á°¤È¤·¤ÆÍѤ¤¤é¤ì¤ë¡£ EXPR ¤ò¾Êά¤·¤¿¾ì¹ç¡¢ FILEHANDLE ¤ÈƱ̾¤Î¥¹¥«¥é¡¼ÊÑ¿ô¤¬¥Õ¥¡¥¤¥ë̾¤ò»ý¤Ä¡£ À®¸ù¤¹¤ì¤Ð non-zero ¤òÊÖ¤·¡¢¤½¤¦¤Ç¤Ê¤¤¾ì¹ç¤Ï undefined ¤òÊÖ¤¹¡£ open ¤¬¥Ñ¥¤¥×¤ò´Þ¤à¾ì¹ç¡¢ÊÖ¤êÃͤϥµ¥Ö¥×¥í¥»¥¹¤Î pid ¤Ë¤Ê¤ë¡£
$article = 100;
open article || die "Can't find article $article: $!\n";
while (<article>) { ...

open(LOG, '>>/usr/spool/news/twitlog');
                # (log ¤ÏͽÌó¸ì¤Ç¤¢¤ë)

open(article, "caesar <$article |");
                # µ­»ö¤ò decrypt ¤¹¤ë

open(extract, "|sort >/tmp/Tmp$$");
                # $$ ¤Ï¸½ºß¤Î¥×¥í¥»¥¹ #

# °ú¿ô¤Î¥Õ¥¡¥¤¥ë¥ê¥¹¥È¤Ë¤Ä¤¤¤Æ
# ¤½¤ì¤¬¥¤¥ó¥¯¥ë¡¼¥É¤¹¤ë¥Õ¥¡¥¤¥ë¤â´Þ¤á¤Æ½èÍý¤¹¤ë

foreach $file (@ARGV) {
     do process($file, 'fh00');    # no pun intended
}

sub process {
     local($filename, $input) = @_;
     $input++;      # ¤³¤ì¤Ïʸ»úÎó¤Î¥¤¥ó¥¯¥ê¥á¥ó¥È¤Ç¤¢¤ë
     unless (open($input, $filename)) {
          print STDERR "Can't open $filename: $!\n";
          return;
     }
     while (<$input>) {       # ´ÖÀÜ»ØÄê¤ËÃí°Õ
          if (/^#include "(.*)"/) {
               do process($1, $input);
               next;
          }
          ...       # whatever
     }
}
Bourne shell ¤Î´·½¬¤Ç¡¢EXPR ¤ò `>&' ¤Ç»Ï¤á¤Æ¤âÎɤ¤¡£ ¤³¤Î¾ì¹ç¡¢»Ä¤ê¤Îʸ»úÎó¤Ï ¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë (¤Þ¤¿¤Ï¿ôÃͤʤé¤Ð ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿)¤È²ò¼á¤µ¤ì¡¢ dup ¤µ¤ì¡¢open ¤µ¤ì¤ë¡£ `&' ¤Ï `>', `>>', `<', `+>', `+>>', `+<' ¤Î¸å¤ÇÍѤ¤¤ÆÎɤ¤¡£ »ØÄꤹ¤ë¥â¡¼¥É¤Ï¸µ¤Î¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤ÈƱ¤¸¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£ °Ê²¼¤Î¥¹¥¯¥ê¥×¥È¤Ï STDOUT ¤ª¤è¤Ó STDERR ¤òÊݸ¤·¡¢ ¥ê¥À¥¤¥ì¥¯¥È¤·¡¢¸µ¤ËÌ᤹¡£
#!/usr/bin/perl
open(SAVEOUT, ">&STDOUT");
open(SAVEERR, ">&STDERR");

open(STDOUT, ">foo.out") || die "Can't redirect stdout";
open(STDERR, ">&STDOUT") || die "Can't dup stdout";

select(STDERR); $| = 1;       # ¥Ð¥Ã¥Õ¥¡¥ê¥ó¥°¤Ê¤·¤Ë¤¹¤ë
select(STDOUT); $| = 1;       # ¥Ð¥Ã¥Õ¥¡¥ê¥ó¥°¤Ê¤·¤Ë¤¹¤ë

print STDOUT "stdout 1\n";    # ¤³¤ì¤Ï¥µ¥Ö¥×¥í¥»¥¹¤Ç¤â
print STDERR "stderr 1\n";    # Ư¤¯

close(STDOUT);
close(STDERR);

open(STDOUT, ">&SAVEOUT");
open(STDERR, ">&SAVEERR");

print STDOUT "stdout 2\n";
print STDERR "stderr 2\n";
¥³¥Þ¥ó¥É `-' ¤òÍѤ¤¤Æ¥Ñ¥¤¥×¤ò open ¤¹¤ë¾ì¹ç¡¢ ¤¹¤Ê¤ï¤Á `|-' ¤Þ¤¿¤Ï`-|' ¤Î¾ì¹ç¡¢ °ÅÌÛ¤ÎÆâ¤Ë fork ¤¬¤Ê¤µ¤ì¡¢ open ¤ÎÊÖ¤êÃÍ¤Ï¿Æ¥×¥í¥»¥¹¤Ç¤Ï»Ò¥×¥í¥»¥¹¤Î pid¡¢ »Ò¥×¥í¥»¥¹¤Ç¤Ï 0 ¤Ë¤Ê¤ë¡£ (open ¤¬À®¸ù¤·¤¿¤«¤É¤¦¤«¤Ï defined($pid) ¤Ç³Î¤«¤á¤ë¡£) ¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤ÎµóÆ°¤Ï¿Æ¥×¥í¥»¥¹¤Ç¤ÏÄ̾ï¤ÈƱ¤¸¤Ç¤¢¤ë¤¬¡¢ ¤½¤Î¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤Ø¤Î i/o ¤Ï »Ò¥×¥í¥»¥¹¤Î STDOUT/STDIN ¤Ë¥Ñ¥¤¥×¤µ¤ì¤ë¡£ »Ò¥×¥í¥»¥¹¤Ç¤Ï¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤Ï open ¤µ¤ì¤Æ¤¤¤Ê¤¤ --- i/o ¤Ï¿·¤¿¤Ê STDOUT¤«¤é/STDIN ¤Ë ¤Ê¤µ¤ì¤ë¡£ Îɤ¯»È¤ï¤ì¤ë¤Î¤Ï¡¢Î㤨¤Ð setuid ¤ÇÁö¤é¤»¤Æ¤¤¤ë¤È¤­¤Ê¤É¡¢ ¥Ñ¥¤¥×¥³¥Þ¥ó¥É¤Î¼Â¹Ô¾õÂÖ¤ò¥³¥ó¥È¥í¡¼¥ë¤·¤¿¤¤»þ¤ä¡¢ ¥·¥§¥ë¥³¥Þ¥ó¥É¤Ë¥á¥¿¥­¥ã¥é¥¯¥¿¡¼¤¬¤¢¤ë¤«¤É¤¦¤«¤ò¥Á¥§¥Ã¥¯¤·¤¿¤¯¤Ê¤¤»þ¤Ç¤¢¤ë¡£ ¼¡¤Î 2 ¤Ä¤Î¥Ú¥¢¤Ï¤½¤ì¤¾¤ì¤¢¤ëÄøÅÙ(more or less)ƱÅù¤Ç¤¢¤ë¡£
open(FOO, "|tr '[a-z]' '[A-Z]'");
open(FOO, "|-") || exec 'tr', '[a-z]', '[A-Z]';

open(FOO, "cat -n '$file'|");
open(FOO, "-|") || exec 'cat', '-n', $file;
ÌÀ¼¨Åª¤Ë¥Ñ¥¤¥×¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤ò close ¤¹¤ë¤È ¿Æ¥×¥í¥»¥¹¤Ï»Ò¥×¥í¥»¥¹¤¬½ªÎ»¤¹¤ë¤Î¤òÂÔ¤Á¡¢¥¹¥Æ¡¼¥¿¥¹ÃÍ $? ¤¬ÊÖ¤êÃͤȤʤ롣 Ãí°Õ:
fork ¤ò¹Ô¤¦Áàºî¤Ë¤ª¤¤¤Æ¤Ï¡¢ ¥Õ¥é¥Ã¥·¥å¤µ¤ì¤Æ¤¤¤Ê¤¤¥Ð¥Ã¥Õ¥¡¤ÏξÊý¤Î¥×¥í¥»¥¹¤Ë¤ª¤¤¤Æ¥Õ¥é¥Ã¥·¥å¤µ¤ì¤º¤Ë»Ä¤ë¡£ ¤Ä¤Þ¤ê¡¢Æó½Å¤Ë½ÐÎϤµ¤ì¤ë¤Î¤òÈò¤±¤ë¤Ë¤Ï¡¢ $| ¤ò¥»¥Ã¥È¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£ See section @hbox{@hbox to 1.6em{@tt@$|@hfil} : write ¤Þ¤¿¤Ï print ¤Î¸å¤Ë¥Õ¥é¥Ã¥·¥å¤ò¹Ô¤¦¤«Èݤ«}. open ¤ËÅϤµ¤ì¤ë¥Õ¥¡¥¤¥ë̾¤ÏºÇ½é¤äºÇ¸å¤Î¥¹¥Ú¡¼¥¹¤ò¼è¤ê½ü¤«¤ì¤ë¡£ ̾Á°¤Ë¤ª¤«¤·¤Êʸ»ú¤¬´Þ¤Þ¤ì¤ë¥Õ¥¡¥¤¥ë¤ò open ¤¹¤ë¤Ë¤Ï¡¢ ¼¡¤Î¤è¤¦¤Ë¤·¤ÆÁ°¸å¤Î¥¹¥Ú¡¼¥¹¤¬¼è¤ê½ü¤«¤ì¤Ê¤¤¤è¤¦¤Ë¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
$file =~ s#^(\s)#./$1#;
open(FOO, "< $file\0");

pipe

`pipe(READHANDLE,WRITEHANDLE)'
Âбþ¤¹¤ë¥·¥¹¥Æ¥à¥³¡¼¥ë¤ÈƱÍÍ¡¢Àܳ¤µ¤ì¤¿¥Ñ¥¤¥×¤Î¥Ú¥¢¤ò¥ª¡¼¥×¥ó¤¹¤ë¡£ ¥Ñ¥¤¥×¤Ç¤Ä¤Ê¤¬¤Ã¤¿¥×¥í¥»¥¹¤Î¥ë¡¼¥×¤Ï¡¢ Ãí°Õ¿¼¤¯¤ä¤é¤Ê¤¤¤È¥Ç¥Ã¥É¥í¥Ã¥¯¤òµ¯¤³¤¹¤Î¤ÇÃí°Õ¡£ ¤µ¤é¤Ë¡¢perl ¤Î¥Ñ¥¤¥×¤Ï stdio ¤Î¥Ð¥Ã¥Õ¥¡¥ê¥ó¥°¤ò»È¤¦¤Î¤Ç¡¢ ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ë¤è¤Ã¤Æ¤Ï¡¢ WRITEHANDLE ¤ò¥³¥Þ¥ó¥ÉËè¤Ë¥Õ¥é¥Ã¥·¥å¤¹¤ë¤¿¤á¤Ë¡¢ $| ¤ò¥»¥Ã¥È¤¹¤ëɬÍפ¬¤¢¤ë¤«¤â¤·¤ì¤Ê¤¤¡£ See section @hbox{@hbox to 1.6em{@tt@$|@hfil} : write ¤Þ¤¿¤Ï print ¤Î¸å¤Ë¥Õ¥é¥Ã¥·¥å¤ò¹Ô¤¦¤«Èݤ«}. [perl 3.0 ¥Ñ¥Ã¥Á¥ì¥Ù¥ë 9 °Ê¾å¤¬É¬Íס£]

print

`print(FILEHANDLE LIST)'
`print(LIST)'
`print FILEHANDLE LIST'
`print LIST'
`print'
ʸ»úÎó¤Þ¤¿¤Ï¥³¥ó¥Þ¤Ç¶èÀÚ¤é¤ì¤¿Ê¸»úÎó¤Î¥ê¥¹¥È¤ò½ÐÎϤ¹¤ë¡£ À®¸ù¤¹¤ì¤Ð non-zero ¤òÊÖ¤¹¡£ FILEHANDLE ¤Ï ¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤Î̾Á°¤òÃͤȤ·¤Æ»ý¤Ä¥¹¥«¥é¡¼ÊÑ¿ô̾¤Ç¤â¤è¤¤¡£ ¤³¤¦¤¹¤ë¤È¡¢1 ¥ì¥Ù¥ë¤Î´ÖÀÜŪ¤Ê½ÐÎϤ¬¤Ç¤­¤ë¡£ (Ãí°Õ: FILEHANDLE ¤¬ÊÑ¿ô¤Ç¡¢¼¡¤Î¥È¡¼¥¯¥ó¤¬Ê¸¤Î½ª¤ï¤ê¤Î¾ì¹ç¤Ï ¤½¤ì¤¬±é»»»Ò¤È¸í²ò¼á¤µ¤ì¤ë²ÄǽÀ­¤¬¤¢¤ë¤Î¤Ç¡¢´Ö¤Ë + ¤òÆþ¤ì¤ë¤«¡¢ °ú¿ô¤Ë³ç¸Ì¤ò¤Ä¤±¤ë¤«¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£) FILEHANDLE ¤ò¾Êά¤¹¤ë¤È¡¢ ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ïɸ½à½ÐÎÏ(¤Þ¤¿¤ÏºÇ¸å¤Ë select ¤µ¤ì¤¿½ÐÎÏ¥Á¥ã¥ó¥Í¥ë --- select() »²¾È See section select.)¤Ë½ÐÎϤ¹¤ë¡£ LIST ¤â¾Êά¤¹¤ë¤È¡¢$_ ¤ò STDOUT ¤Ë½ÐÎϤ¹¤ë¡£ ¥Ç¥Õ¥©¥ë¥È¤Î½ÐÎÏ¥Á¥ã¥ó¥Í¥ë¤ò STDOUT °Ê³°¤Î¤â¤Î¤Ë¤¹¤ë¤Ë¤Ï¡¢ select±é»»»Ò¤ò»ÈÍѤ¹¤ë¡£ Ãí°Õ:
print ¤Ï¥ê¥¹¥È¤ò°ú¿ô¤Ë¼è¤ë¤Î¤Ç¡¢ LIST ¤ÎÍ×ÁǤÏÁ´¤ÆÇÛÎó¤Î¥³¥ó¥Æ¥­¥¹¥È¤Çɾ²Á¤µ¤ì¡¢ ¤Þ¤¿¥µ¥Ö¥ë¡¼¥Á¥ó¤ò¥³¡¼¥ë¤¹¤ë¤È ¤½¤Î 1 ¤Ä°Ê¾å¤Î expression ¤ÏÇÛÎó¤Î¥³¥ó¥Æ¥­¥¹¥È¤Çɾ²Á¤µ¤ì¤ë¡£? ¤Þ¤¿¡¢¥­¡¼¥ï¡¼¥É print ¤Î¸å¤Ëº¸³ç¸Ì¤Ï¤Ä¤±¤Ê¤¤¤è¤¦¤ËÃí°Õ¤¹¤ëɬÍפ¬¤¢¤ë (print ¤Ø¤Î°ú¿ô¤ò¶èÀÚ¤ë --- + ¤ò´Ö¤ËÆþ¤ì¤ë¤«Á´°ú¿ô¤ò³ç¸Ì¤Ç°Ï¤à --- ¤¿¤á¤ËÂбþ¤·¤¿±¦³ç¸Ì¤ò¤Ä¤±¤¿¤¤¾ì¹ç¤ò½ü¤¤¤Æ)¡£

printf

`printf(FILEHANDLE LIST)'
`printf(LIST)'
`printf FILEHANDLE LIST'
`printf LIST'
print FILEHANDLE sprintf(LIST) ¤ÈƱÅù¤Ç¤¢¤ë¡£ See section print, ¤ª¤è¤Ó See section sprintf.

read

`read(FILEHANDLE,SCALAR,LENGTH,OFFSET)'
`read(FILEHANDLE,SCALAR,LENGTH)'
»ØÄꤷ¤¿ FILEHANDLE ¤«¤é¡¢ LENGTH ¥Ð¥¤¥È¤Î¥Ç¡¼¥¿¤òÆɤó¤Ç SCALAR ¤Ë³ÊǼ¤¹¤ë¡£ ¼ÂºÝ¤ËÆɤ߹þ¤ó¤À¥Ð¥¤¥È¿ô¡¢¤Þ¤¿¤Ï¥¨¥é¡¼¤¬¤¢¤ì¤Ð undef ¤òÊÖ¤¹¡£ SCALAR ¤Ï¼ÂºÝ¤ËÆɤó¤À¥Ð¥¤¥È¿ô¤Ë¹ç¤ï¤»¤Æ¥µ¥¤¥º¤¬ÊѤï¤ë¡£ OFFSET ¤ò»ØÄꤹ¤ë¤È¡¢ Æɤó¤À¥Ç¡¼¥¿¤òʸ»úÎó¤ÎÀèƬ¤Ç¤Ï¤Ê¤¯Â¾¤Î¾ì½ê¤Ë³ÊǼ¤¹¤ë¡£ ¤³¤ì¤Ï¼ÂºÝ¤Ë¤Ï¡¢ stdio ¤Î fread ¥³¡¼¥ë¤òÍѤ¤¤Æ¥¤¥ó¥×¥ê¥á¥ó¥È¤·¤Æ¤¤¤ë¡£ ËÜÅö¤Î read ¥·¥¹¥Æ¥à¥³¡¼¥ë¤ò»È¤¤¤¿¤±¤ì¤Ð¡¢sysread ¤ò»²¾È¤»¤è¡£See section sysread.

seek

`seek(FILEHANDLE,POSITION,WHENCE)'
FILEHANDLE ¤Î¥Õ¥¡¥¤¥ë¥Ý¥¤¥ó¥¿¤òǤ°Õ¤Î°ÌÃ֤˰ÜÆ°¤¹¤ë¡£ stdio ¤Î fseek() ¤ÈƱ¤¸¤Ç¤¢¤ë¡£ FILEHANDLE ¤Ï¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤Î̾Á°¤òÃͤȤ·¤Æ»ý¤Ä expression ¤Ç¤â¤è¤¤¡£ À®¸ù¤¹¤ì¤Ð 1¡¢¤½¤¦¤Ç¤Ê¤±¤ì¤Ð 0 ¤Ç¤¢¤ë¡£

sprintf

`sprintf(FORMAT,LIST)'
Ä̾ï¤Î printf ¤Î½¬´·¤Ç¥Õ¥©¡¼¥Þ¥Ã¥È¤µ¤ì¤¿Ê¸»úÎó¤òÊÖ¤¹¡£
ʸ»ú `*' ¤Ï¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Ê¤¤¡£

sysread

`sysread(FILEHANDLE,SCALAR,LENGTH,OFFSET)'
`sysread(FILEHANDLE,SCALAR,LENGTH)'
¥·¥¹¥Æ¥à¥³¡¼¥ë read(2) ¤òÍѤ¤¤Æ¡¢ »ØÄꤷ¤¿¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤«¤é ÊÑ¿ô SCALAR ¤Ë LENGTH ¥Ð¥¤¥È¤Î¥Ç¡¼¥¿¤òÆɤ߹þ¤à¡£ ¤³¤ì¤Ï stdio ¤ò·Ðͳ¤·¤Ê¤¤¤Î¤Ç¡¢ ¾¤Î¼ïÎà¤ÎÆɤ߹þ¤ß¤È°ì½ï¤Ë»È¤¦¤Èº®Í𤹤뤳¤È¤¬¤¢¤ë¡£ ¼ÂºÝ¤ËÆɤó¤À¥Ð¥¤¥È¿ô¤òÊÖ¤¹¡£¥¨¥é¡¼¤¬¤¢¤Ã¤¿¾ì¹ç¤Ï undef ¤òÊÖ¤¹¡£ Æɤ߹þ¤ó¤À¥Ç¡¼¥¿¤òʸ»úÎó¤ÎÀèƬ¤«¤é¤Ç¤Ï¤Ê¤¯Ê̤ΰÌÃ֤˳ÊǼ¤¹¤ë¤¿¤á¤Ë¡¢ OFFSET ¤ò»ØÄꤷ¤Æ¤â¤è¤¤¡£

syswrite

`syswrite(FILEHANDLE,SCALAR,LENGTH,OFFSET)'
`syswrite(FILEHANDLE,SCALAR,LENGTH)'
¥·¥¹¥Æ¥à¥³¡¼¥ë write(2) ¤òÍѤ¤¤Æ¡¢ »ØÄꤷ¤¿¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤Ë ÊÑ¿ô SCALAR ¤«¤é LENGTH ¥Ð¥¤¥È¤Î¥Ç¡¼¥¿¤ò½ñ¤­¹þ¤à¡£ ¤³¤ì¤Ï stdio ¤ò·Ðͳ¤·¤Ê¤¤¤Î¤Ç¡¢ print ¤È°ì½ï¤Ë»È¤¦¤Èº®Í𤹤뤳¤È¤¬¤¢¤ë¡£ ¼ÂºÝ¤Ë½ñ¤­¹þ¤ó¤À¥Ð¥¤¥È¿ô¤òÊÖ¤¹¡£¥¨¥é¡¼¤¬¤¢¤Ã¤¿¾ì¹ç¤Ï undef ¤òÊÖ¤¹¡£ ½ñ¤­¹þ¤à¥Ç¡¼¥¿¤òʸ»úÎó¤ÎÀèƬ¤«¤é¤Ç¤Ï¤Ê¤¯Ê̤ΰÌÃÖ¤«¤é¼è¤ê½Ð¤¹¤¿¤á¤Ë¡¢ OFFSET ¤ò»ØÄꤷ¤Æ¤â¤è¤¤¡£

tell

`tell(FILEHANDLE)'
`tell FILEHANDLE'
`tell'
FILEHANDLE ¤Î¸½ºß¤Î¥Õ¥¡¥¤¥ë°ÌÃÖ¤òÊÖ¤¹¡£ FILEHANDLE ¤Ï ¼ÂºÝ¤Î¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤Î̾Á°¤òÃͤȤ·¤Æ»ý¤Ä expression ¤Ç¤¢¤Ã¤Æ¤â¤è¤¤¡£ FILEHANDLE ¤ò¾Êά¤¹¤ë¤È¡¢ºÇ¸å¤ËÆɤó¤À¥Õ¥¡¥¤¥ë¤ò²¾Äꤹ¤ë¡£

write

`write(FILEHANDLE)'
`write(EXPR)'
`write'
¥ì¥³¡¼¥É¤ò¥Õ¥©¡¼¥Þ¥Ã¥È¤·¤Æ(Ê£¿ô¹Ô¤Ç¤â¤è¤¤)»ØÄꤷ¤¿¥Õ¥¡¥¤¥ë¤Ë½ÐÎϤ¹¤ë¡£ ¤½¤ÎºÝ¡¢¤½¤Î¥Õ¥¡¥¤¥ë¤Ë»ØÄꤵ¤ì¤Æ¤¤¤ë¥Õ¥©¡¼¥Þ¥Ã¥È¤òÍѤ¤¤ë¡£ ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¥Õ¥¡¥¤¥ë¤Î¥Õ¥©¡¼¥Þ¥Ã¥È¤Ï¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤ÈƱ̾¤Î¤â¤Î¤À¤¬¡¢ ¥«¥ì¥ó¥È½ÐÎÏ¥Á¥ã¥ó¥Í¥ë(select »²¾È)¤Î¥Õ¥©¡¼¥Þ¥Ã¥È¤Ï ¥Õ¥©¡¼¥Þ¥Ã¥È¤Î̾Á°¤ò $~ ¤Ë»ØÄꤹ¤ë¤³¤È¤ÇÌÀ¼¨¤Ç¤­¤ë¡£ See section @hbox{@hbox to 1.6em{@tt@$~@hfil} : ½ÐÎÏ¥Á¥ã¥ó¥Í¥ë¤Î¸½ºß¤Î¥ì¥Ý¡¼¥È¥Õ¥©¡¼¥Þ¥Ã¥È̾}. À°·ÁÁàºî¤Ï¼«Æ°Åª¤Ë¹Ô¤ï¤ì¤ë¡£ ¸½ºß¤Î¥Ú¡¼¥¸¤Ë¥Õ¥©¡¼¥Þ¥Ã¥È¤·¤¿¥ì¥³¡¼¥É¤ËÂФ·¤Æ½¼Ê¬¤Ê;͵¤¬¤Ê¤¤¾ì¹ç¤Ï ²þÊǤò½ÐÎϤ·¤Æ¼¡¤Î¥Ú¡¼¥¸¤Ë°Ü¤ê¡¢ ¿·¤·¤¤¥Ú¡¼¥¸¤Î¥Ø¥Ã¥À¡¼¤ò¥Õ¥©¡¼¥Þ¥Ã¥È¤¹¤ë¤Ë¤Ï Æüì¤Ê¥Ú¡¼¥¸ÀèƬ¥Õ¥©¡¼¥Þ¥Ã¥È¤¬»È¤ï¤ì¡¢ ¤³¤¦¤·¤Æ¥ì¥³¡¼¥É¤¬½ÐÎϤµ¤ì¤ë¡£ ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¥Ú¡¼¥¸ÀèƬ¥Õ¥©¡¼¥Þ¥Ã¥È¤Ï ¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë̾¤Ë "_TOP" ¤ò¤Ä¤±¤¿¤â¤Î¤Ç¤¢¤ë¤¬¡¢ ¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤¬ select ¤µ¤ì¤Æ¤¤¤ë»þ¤Ë $^ ¤ËÂåÆþ¤¹¤ë¤³¤È¤Ç ¹¥¤ß¤Î¥Õ¥©¡¼¥Þ¥Ã¥È¤ËưŪ¤ËÊѹ¹¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£ See section @hbox{@hbox to 1.6em{@tt@$^@hfil} : ½ÐÎÏ¥Á¥ã¥ó¥Í¥ë¤Î¸½ºß¤Î¥Ú¡¼¥¸¥È¥Ã¥×̾}. ¸½ºß¤Î¥Ú¡¼¥¸¤Ë»Ä¤Ã¤Æ¤¤¤ë¹Ô¿ô¤ÏÊÑ¿ô $- ¤ËÆþ¤Ã¤Æ¤ª¤ê¡¢ ¤³¤ì¤ò 0 ¤Ë¥»¥Ã¥È¤·¤Æ¶¯À©Åª¤Ë¿·¤·¤¤¥Ú¡¼¥¸¤ËÆþ¤ë¤³¤È¤¬¤Ç¤­¤ë¡£ FILEHANDLE ¤ò»ØÄꤷ¤Ê¤¤¾ì¹ç¤Ï¡¢ ½ÐÎϤϸ½ºß¤Î¥Ç¥Õ¥©¥ë¥È½ÐÎÏ¥Á¥ã¥ó¥Í¥ë¤Ë¤Ê¤µ¤ì¤ë¡£ ¤³¤ì¤ÏºÇ½é¤Ï STDOUT ¤Ç¡¢select ¤òÍѤ¤¤ÆÊѹ¹²Äǽ¤Ç¤¢¤ë¡£ FILEHANDLE ¤¬ expression ¤Î¾ì¹ç¤Ï¡¢¼Â¹Ô»þ¤Ë expression ¤¬É¾²Á¤µ¤ì¡¢ ¤½¤Î·ë²Ì¤Îʸ»úÎó¤¬ FILEHANDLE ¤Î̾Á°¤È¤·¤ÆÍѤ¤¤é¤ì¤ë¡£ format ¤Ë¤Ä¤¤¤Æ¤Î¾ÜºÙ¤Ï¡¢¥Õ¥©¡¼¥Þ¥Ã¥È¤Î¾Ï¤ò»²¾È¤Î¤³¤È¡£
See section ¥Õ¥©¡¼¥Þ¥Ã¥È. Ãí°Õ: write ¤Ï read ¤ÎÈ¿ÂФǤϤʤ¤¡£

¸¡º÷¡¦ÃÖ´¹´Ø¿ô

/¥Ñ¥¿¡¼¥ó/

`/PATTERN/gio'
m/¥Ñ¥¿¡¼¥ó/ ¤ÈƱ¤¸¡£¼¡¹à¤ò»²¾È¡£

m/¥Ñ¥¿¡¼¥ó/

`m/PATTERN/gio'
`/PATTERN/gio'
ʸ»úÎóÃæ¤Î¥Ñ¥¿¡¼¥ó¥Þ¥Ã¥Á¤ò¸¡º÷¤·¡¢ true(1) ¤Þ¤¿¤Ï false(")¤òÊÖ¤¹¡£ =~ ¤ä !~ ¤Çʸ»úÎó¤ò»ØÄꤷ¤Ê¤¤¾ì¹ç¤Ï $_ ʸ»úÎó¤ò¸¡º÷¤¹¤ë¡£ (=~ ¤Ç»ØÄꤵ¤ì¤ëʸ»úÎó¤Ïº¸ÊÕÃͤǤ¢¤ëɬÍפϤʤ¤ --- expression ɾ²Á¤Î·ë²Ì¤Ç¤âÎɤ¤¤¬¡¢ =~ ¤ÎÊý¤¬Í¥ÀèÅÙ¤¬¹â¤¤¤³¤È¤ËÃí°Õ¡£) Àµµ¬É½¸½¤Î¾Ï¤â»²¾È¤Î¤³¤È¡£ See section Àµµ¬É½¸½. / ¤¬ delimiter ¤Ç¤¢¤ë¤Ê¤é¡¢ºÇ½é¤Î m ¤Ï¾Êά²Äǽ¤Ç¤¢¤ë¡£ m ¤ò»È¤¦¤È¡¢ ¥¢¥ë¥Õ¥¡¥Ù¥Ã¥È¡¦¿ô»ú¤Ç¤Ê¤¤Ç¤°Õ¤Îʸ»ú¤Î¥Ú¥¢¤ò delimiter ¤È¤·¤Æ»È¤¨¤ë¡£ ¤³¤ì¤Ï Unix ¤Î¥Ñ¥¹Ì¾(/ ¤ò´Þ¤à)¤Î¥Þ¥Ã¥Á¥ó¥°¤ò¤¹¤ë¤Î¤ËÊØÍø¤Ç¤¢¤ë¡£ Æó¤ÄÌܤÎdelimiter ¤Î¸å¤Ë¥ª¥×¥·¥ç¥ó i ¤ò¤Ä¤±¤ë¤È¡¢ case insensitive ¤Ç¥Þ¥Ã¥Á¥ó¥°¤ò¹Ô¤¦¡£ PATTERN ¤Ï¥¹¥«¥é¡¼ÊÑ¿ô¤ò´Þ¤ó¤Ç¤¤¤Æ¤âÎɤ¤¤¬¡¢ ¥Ñ¥¿¡¼¥ó¸¡º÷¤ò¹Ô¤¦Ëè¤ËÃÖ¤­´¹¤¨¤¬¹Ô¤ï¤ì¤ë(¤½¤·¤Æ¥Ñ¥¿¡¼¥ó¤¬ºÆ¥³¥ó¥Ñ¥¤¥ë¤µ¤ì¤ë)¡£ (Ãí°Õ: $) ¤È $| ¤Ï ʸ»úÎó¤Î½ª¤ï¤ê¤Î¥Á¥§¥Ã¥¯¤Ë»È¤ï¤ì¤ë¤Ç¤¢¤í¤¦¤«¤é¡¢ ÃÖ¤­´¹¤¨¤Ï¹Ô¤ï¤ì¤Ê¤¤¡£) ¥Ñ¥¿¡¼¥ó¤òºÇ½é¤Î°ì²ó¤À¤±¥³¥ó¥Ñ¥¤¥ë¤µ¤»¤¿¤¤»þ¤Ï¡¢ ºÇ¸å¤Î¥ª¥×¥·¥ç¥ó¤Ë o ¤ò»ØÄꤹ¤ë¡£ ¤³¤¦¤¹¤ë¤È¼Â¹Ô»þ¤ÎºÆ¥³¥ó¥Ñ¥¤¥ë¤òÈò¤±¤ë¤³¤È¤¬¤Ç¤­¤ë¤Î¤Ç¡¢ ÊÑ¿ô¤ÇÃÖ¤­´¹¤¨¤Æ¤¤¤ëÃͤ¬¥¹¥¯¥ê¥×¥È¼Â¹ÔÃæ¤ËÊѤï¤é¤Ê¤¤¤Î¤Ç¤¢¤ì¤Ð¡¢ÊØÍø¤Ç¤¢¤ë¡£ PATTERN ¤¬¥Ì¥ëʸ»úÎó¤Ëɾ²Á¤µ¤ì¤¿¾ì¹ç¡¢ ľÁ°¤ËÀ®¸ù¤·¤¿Àµµ¬É½¸½¤¬Âå¤ï¤ê¤ËÍѤ¤¤é¤ì¤ë¡£ ÇÛÎóÃͤ¬É¬ÍפÊʸ̮¤Ç»È¤¦¤È¡¢¥Ñ¥¿¡¼¥ó¥Þ¥Ã¥Á¤Ï¥Ñ¥¿¡¼¥ó¤ò³ç¸Ì¤Ç¤¯¤¯¤Ã¤¿¤â¤Î¡¢ ¤¹¤Ê¤ï¤Á ($1, $2, $3 ...) ¤Ë¥Þ¥Ã¥Á¤¹¤ë subexpression ¤«¤é¤Ê¤ë ÇÛÎó¤òÊÖ¤¹¡£¼ÂºÝ¤Ë¤Ï $1¡¢$2 ¤Ê¤É¤ò¥»¥Ã¥È¤»¤º¡¢ ¤³¤Î¾ì¹ç¤À¤È¡¢$+¡¢$`¡¢$&¡¢$' ¤â¥»¥Ã¥È¤·¤Ê¤¤¡£ ¥Þ¥Ã¥Á¥ó¥°¤¬¼ºÇÔ¤·¤¿¾ì¹ç¡¢¥Ì¥ëÇÛÎó¤¬Ê֤롣
¥Þ¥Ã¥Á¥ó¥°¤¬À®¸ù¤·¤¿¾ì¹ç¡¢³ç¸Ì¤¬°ì¤Ä¤â¤Ê¤±¤ì¤Ð¡¢ÇÛÎóÃÍ (1) ¤¬Ê֤롣
open(tty, '/dev/tty');
<tty> =~ /^y/i && do foo();    # y ¤ÈÅú¤¨¤¿¤é do foo

if (/Version: *([0-9.]*)/) { $version = $1; }

next if m#^/usr/spool/uucp#;

# poor man's grep
$arg = shift;
while (<>) {
     print if /$arg/o;    #  1 ²ó¤À¤±¥³¥ó¥Ñ¥¤¥ë¤¹¤ë
}

if (($F1, $F2, $Etc) = ($foo =~ /^(\S+)\s+(\S+)\s*(.*)/))
ºÇ¸å¤ÎÎã¤Ï¡¢$foo ¤òÆó¤Ä¤Î word ¤È»Ä¤ê¤Ëʬ¤±¡¢ ¤³¤ì¤é»°¤Ä¤Î¥Õ¥£¡¼¥ë¥É¤ò $F1, $F2, $Etc ¤ËÂåÆþ¤¹¤ë¡£ ¤É¤ÎÊÑ¿ô¤¬Êѹ¹¤µ¤ì¤Æ¤â¡¢¤¹¤Ê¤ï¤Á¡¢¥Ñ¥¿¡¼¥ó¤¬¥Þ¥Ã¥Á¤¹¤ì¤Ð¡¢¾ò·ï¤Ï¿¿¤Ç¤¢¤ë¡£ ½¤¾þ»Ò "g" ¤Ï¥°¥í¡¼¥Ð¥ë¥Ñ¥¿¡¼¥ó¥Þ¥Ã¥Á¤ò»ØÄꤹ¤ë -- ¤¹¤Ê¤ï¤Á¡¢ ʸ»úÎóÃæ¤Ç²Äǽ¤Ê¤«¤®¤ê¥Þ¥Ã¥Á¤ò¹Ô¤¦¡£ ¥³¥ó¥Æ¥­¥¹¥È¤Ë¤è¤ê¤É¤Î¤è¤¦¤Ë¿¶Éñ¤¦¤«¡£ ÇÛÎó¤Î¥³¥ó¥Æ¥­¥¹¥È¤Ç¤Ï¡¢ Àµµ¬É½¸½Ãæ¤Î¤¹¤Ù¤Æ¤Î³ç¸Ì¤È¥Þ¥Ã¥Á¤¹¤ë substring ¤«¤é¤Ê¤ë¥ê¥¹¥È¤òÊÖ¤¹¡£ ³ç¸Ì¤¬°ì¤Ä¤â¤Ê¤¤¾ì¹ç¡¢¥Ñ¥¿¡¼¥óÁ´ÂΤβó¤ê¤Ë³ç¸Ì¤¬¤¢¤ë¤«¤Î¤è¤¦¤Ë°·¤¤¡¢ ¥Þ¥Ã¥Á¤·¤¿Á´Ê¸»úÎó¤Î¥ê¥¹¥È¤òÊÖ¤¹¡£ ¥¹¥«¥é¡¼¤Î¥³¥ó¥Æ¥­¥¹¥È¤Ç¤Ï¡¢Ê¸»úÎóÁ´ÂΤˤĤ¤¤Æ·«¤êÊÖ¤·¤ò¹Ô¤¤¡¢ ¥Þ¥Ã¥Á¤¹¤ëÅÙ¤Ë TRUE ¤òÊÖ¤·¡¢¤Ä¤¤¤Ë¥Þ¥Ã¥Á¤·¤Ê¤¯¤Ê¤Ã¤¿»þÅÀ¤Ç FALSE ¤òÊÖ¤¹¡£ (¸À¤¤Âؤ¨¤ì¤Ð¡¢Á°¤Ë¤É¤³¤Þ¤Ç¥Þ¥Ã¥Á¤ò¹Ô¤Ê¤Ã¤¿¤«¤ò³Ð¤¨¤Æ¤ª¤­¡¢ ¤½¤Î°ÌÃÖ¤«¤é¸¡º÷¤òºÆ³«¤¹¤ë¡£) ºÇ¸å¤Î¥Þ¥Ã¥Á¤ò¹Ô¤Ê¤Ã¤Æ¤«¤éʸ»úÎó¤òÊѹ¹¤·¤Æ¤¤¤Ê¤¤¤È¤¤¤¦¤³¤È¤ò²¾Äꤷ¤Æ¤¤¤ë¡£ ¥Þ¥Ã¥Á¤Î´Ö¤Çʸ»úÎó¤òÊѹ¹¤¹¤ë¤È̤ÄêµÁ¤ÎÆ°ºî¤ò¹Ô¤¦²ÄǽÀ­¤¬¤¢¤ë¡£ (¼Â¤Ï¡¢substr() ¤ò»È¤Ã¤ÆÁ´Ê¸»úÎó¤ÎŤµ¤òÊѤ¨¤Ê¤¤¤Ç ʸ»úÎó¤ò¤½¤Î¾ì¤Ç(in-place)Êѹ¹¤¹¤ë¾ì¹ç¤Ë¤Ï¤¦¤Þ¤¯¤¤¤¯¡£¤·¤«¤·¡¢°ìÈÌŪ¤Ë¤Ï¡¢ ¤½¤Î¤è¤¦¤ÊÊѹ¹¤ò¹Ô¤¦¾ì¹ç¤Ï s//g ¤ò»È¤¦¤Ù¤­¤Ç¤¢¤ë¡£) Îã:
# array context
($one,$five,$fifteen) = (`uptime` =~ /(\d+\.\d+)/g);

# scalar context
$/ = ""; $* = 1;
while ($paragraph = <>) {
    while ($paragraph =~ /[a-z]['")]*[.!?]+['")]*\s/g) {
     $sentences++;
    }
}
print "$sentences\n";

?¥Ñ¥¿¡¼¥ó?

`?PATTERN?'
reset ¤«¤é reset ¤Þ¤Ç¤Ç 1 ²ó¤·¤«¥Þ¥Ã¥Á¤·¤Ê¤¤¤³¤È¤ò½ü¤¤¤Æ¡¢ /¥Ñ¥¿¡¼¥ó/ ¸¡º÷¤ÈƱ¤¸¤Ç¤¢¤ë¡£Î㤨¤Ð¡¢´ö¤Ä¤«¤¢¤ë¥Õ¥¡¥¤¥ë¤Î³Æ¡¹¤Ë¤Ä¤¤¤Æ¡¢ ¤¢¤ë¤â¤Î¤¬ºÇ½é¤Ë¸½¤ì¤ë¤Î¤òÄ´¤Ù¤ë¤Î¤ËÊØÍø¤Ç¤¢¤ë¡£ ¸½ºß¤Î¥Ñ¥Ã¥±¡¼¥¸¤Ë¥í¡¼¥«¥ë¤Ê ?? ¥Ñ¥¿¡¼¥ó¤Î¤ß¥ê¥»¥Ã¥È¤µ¤ì¤ë¡£ See section reset.

s/¥Ñ¥¿¡¼¥ó/ÃÖ¤­´¹¤¨/

`s/PATTERN/REPLACEMENT/gieo'
PATTERN ¤ò»ý¤Äʸ»úÎó¤ò¸¡º÷¤·¡¢ ¸«¤Ä¤«¤ì¤Ð¡¢REPLACEMENT ¥Æ¥­¥¹¥È¤ÈÃÖ¤­´¹¤¨¡¢ÃÖ´¹¤ò¹Ô¤Ã¤¿¿ô¤òÊÖ¤¹¡£ ¸«¤Ä¤«¤é¤Ê¤±¤ì¤Ð false(¤Ä¤Þ¤ê 0)¤òÊÖ¤¹¡£ ¥ª¥×¥·¥ç¥ó¤È¤·¤Æ `g' ¤ò¤Ä¤±¤ë¤È¡¢ ¸«¤Ä¤«¤Ã¤¿Á´¤Æ¤Î¥Ñ¥¿¡¼¥ó¤Ë¤Ä¤¤¤ÆÃÖ´¹¤ò¹Ô¤¦¡£ `e' ¤âƱÍͤ˥ª¥×¥·¥ç¥ó¤Ç¡¢ REPLACEMENT ¤Ï "" ¤Ç³ç¤é¤ì¤¿Ê¸»úÎó¤Ç¤Ï¤Ê¤¯¡¢ expression ¤È¤·¤Æɾ²Á¤µ¤ì¤ë¡£ ¥¹¥é¥Ã¥·¥å¤ÎÂå¤ï¤ê¤Ë ¥¢¥ë¥Õ¥¡¥Ù¥Ã¥È¡¦¿ô»ú¤Ç¤Ê¤¤Ç¤°Õ¤Îʸ»ú¤ò delimiter ¤È¤·¤Æ¤è¤¤¡£ =~ ±é»»»Ò ¤ä !~ ±é»»»Ò¤òÄ̤·¤Æʸ»úÎó¤ò»ØÄꤷ¤Ê¤±¤ì¤Ð¡¢ $_ ¤Ë¤Ä¤¤¤Æ¸¡º÷¤·¡¢ÃÖ´¹¤¹¤ë¡£ (=~ ¤òÍѤ¤¤Æ»ØÄꤹ¤ëʸ»úÎó¤Ï¥¹¥«¥é¡¼ÊÑ¿ô¡¢ÇÛÎó¤ÎÍ×ÁÇ¡¢ ¤Þ¤¿¤Ï¤³¤ì¤é 2 ¤Ä¤Ø¤ÎÂåÆþ¡¢Â¨¤Á¡¢º¸ÊÕÃͤǤʤ±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£) PATTERN ¤¬ $ ¤ò´Þ¤ß¡¢ "ʸ»úÎóºÇ¸å"¤Ç¤Ï¤Ê¤¯¤Æ"ÊÑ¿ô"¤Ë¸«¤¨¤ë¾ì¹ç¤Ï¡¢ ¼Â¹Ô»þ¤Ë¤½¤ÎÊÑ¿ô¤¬ PATTERN ¤Ë½ñ¤­¹þ¤Þ¤ì¤ë¡£ ¥Ñ¥¿¡¼¥ó¤Î¥³¥ó¥Ñ¥¤¥ë¤òºÇ½é¤Î°ì²ó¤À¤±¤Ë¤·¡¢ÊÑ¿ô¤Î½ñ¤­´¹¤¨¤ò¹Ô¤¤¤¿¤¤»þ¤Ï¡¢ `o' ¤òºÇ¸å¤Ë¤Ä¤±¤ë¡£PATTERN ¤¬¥Ì¥ëʸ»úÎó¤Ëɾ²Á¤µ¤ì¤¿¾ì¹ç¡¢ ľÁ°¤ËÀ®¸ù¤·¤¿Àµµ¬É½¸½¤¬Âå¤ï¤ê¤ËÍѤ¤¤é¤ì¤ë¡£Àµµ¬É½¸½¤Î¹à¤ò»²¾È¡£
s/\bgreen\b/mauve/g;      # wintergreen ¤ÏÊѹ¹¤·¤Ê¤¤

$path =~ s|/usr/bin|/usr/local/bin|;

s/Login: $foo/Login: $bar/; # ¼Â¹Ô»þ¤Ë·è¤Þ¤ë¥Ñ¥¿¡¼¥ó

($foo = $bar) =~ s/bar/foo/;

$_ = 'abc123xyz';
s/\d+/$&*2/e;        # 'abc246xyz' ¤ò½ÐÎÏ
s/\d+/sprintf("%5d",$&)/e;     # 'abc  246xyz' ¤ò½ÐÎÏ
s/\w/$& x 2/eg;      # 'aabbcc  224466xxyyzz' ¤ò½ÐÎÏ

s/([^ ]*) *([^ ]*)/$2 $1/;     # ºÇ½é¤Î 2 ¥Õ¥£¡¼¥ë¥É¤òÆþ¤ìÂؤ¨
Ãí°Õ:
ºÇ¸å¤ÎÎã¤Ç \ ¤ÎÂå¤ï¤ê¤Ë $ ¤ò»ÈÍѤ·¤Æ¤¤¤ë¤³¤È¤ËÃí°Õ¡£ Àµµ¬É½¸½¤Î¹à¤ò»²¾È¡£ See section Àµµ¬É½¸½.

study

`study(SCALAR)'
`study SCALAR'
`study'
SCALAR(»ØÄꤷ¤Ê¤±¤ì¤Ð $_)¤Ë¤Ä¤¤¤Æ¡¢ ¤½¤ì¤¬¼¡¤ËÊѹ¹¤µ¤ì¤ëÁ°¤Ë¿¤¯¤Î¥Ñ¥¿¡¼¥ó¥Þ¥Ã¥Á¤ò¤¢¤é¤«¤¸¤á¹Ô¤¦¡£ ¸¡º÷¤ò¹Ô¤¦¥Ñ¥¿¡¼¥ó¤ÎÀ­¼Á¤ä¿ô¡¢¸¡º÷¤µ¤ì¤ëʸ»úÎóÃæ¤Îʸ»ú¤ÎÉÑÅÙʬÉۤˤè¤ê »þ´Ö¤¬ÀáÌ󤵤ì¤ë¤«¤â¤·¤ì¤Ê¤¤¤·¡¢¤µ¤ì¤Ê¤¤¤«¤â¤·¤ì¤Ê¤¤¡£ ¿ʬ¤³¤ì¤ò»ÈÍѤ¹¤ë¤Î¤È¤·¤Ê¤¤¤Î¤È¡¢ ¤É¤Á¤é¤¬Á᤯¼Â¹Ô¤Ç¤­¤ë¤«¤òÈæ³Ó¤·¤Æ¤ß¤¿¤¤¤Ç¤¢¤í¤¦¡£ ¿ô¿¤¯¤Îû¤¤Äê¿ôʸ»úÎó(¤è¤êÊ£»¨¤Ê¥Ñ¥¿¡¼¥óÃæ¤ÎÄê¿ôÉô¤ò´Þ¤à)¤Ë¤Ä¤¤¤Æ ¸¡º÷¤ò¹Ô¤¦¥ë¡¼¥×¤Ë¤ª¤¤¤ÆºÇ¤â¸ú²Ì¤¬¤¢¤ë¤À¤í¤¦¡£ Ʊ»þ¤Ë 1 ¤Ä¤·¤« study ¤Ç¤­¤Ê¤¤¡£ Ê̤Υ¹¥«¥é¡¼¤ò study ¤¹¤ë¤È¡¢ ºÇ½é¤Ë study ¤·¤¿Êý¤Ï unstudied ¤Ë¤Ê¤Ã¤Æ¤·¤Þ¤¦¡£ (study ¤ÎÆ°ºî¤Ï¼¡¤Î¤è¤¦¤Ë¤Ê¤ë: ¸¡º÷ÂоݤÎʸ»úÎó¤ÎÁ´Ê¸»ú¤Î linked list ¤òºî¤ê¡¢¤³¤ì¤Ë¤è¤ê¡¢Î㤨¤Ð¡¢ Á´¤Æ¤Î `k' ¤È¤¤¤¦Ê¸»ú¤¬¤É¤³¤Ë¤¢¤ë¤«¤¬¤ï¤«¤ë¡£ C ¥×¥í¥°¥é¥à¤ª¤è¤Ó±Ñʸ¤«¤éÆÀ¤¿Åý·×Ū¤ÊÉÑÅ٥ơ¼¥Ö¥ë¤Ë´ð¤Å¤¤¤Æ¡¢ ³Æ¸¡º÷ʸ»úÎ󤫤éºÇ¤âµ©¤Êʸ»ú¤òÁª¤Ö¡£ ¤³¤Î"ºÇ¤âµ©¤Ê"ʸ»ú¤ò´Þ¤à°ÌÃ֤ΤߤòÄ´¤Ù¤ë¤Î¤Ç¤¢¤ë¡£) Î㤨¤Ð¡¢¼¡¤Î¥ë¡¼¥×¤Ï¡¢¤¢¤ë¥Ñ¥¿¡¼¥ó¤ò´Þ¤à¹Ô¤ÎÁ°¤Ë¡¢ ¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò´Þ¤à¥¨¥ó¥È¥ê¤ò½ÐÎϤ¹¤ë¤â¤Î¤Ç¤¢¤ë¡£
while (<>) {
     study;
     print ".IX foo\n" if /\bfoo\b/;
     print ".IX bar\n" if /\bbar\b/;
     print ".IX blurfl\n" if /\bblurfl\b/;
     ...
     print;
}
/\bfoo\b/ ¤ò¸¡º÷¤¹¤ë»þ¤Ï¡¢ $_ Ãæ¤Î `f' ¤Î°ÌÃ֤ΤߤòÄ´¤Ù¤ë¡£ ¤Ê¤¼¤Ê¤é¡¢`f' ¤Ï `o' ¤è¤ê¤âµ©¤À¤«¤é¤Ç¤¢¤ë¡£ °ìÈÌŪ¤Ë¡¢Æüì¤Ê¾ì¹ç¤ò½ü¤¤¤Æ¤³¤ì¤Ï¸ú²Ì¤¬¤¢¤ë¡£ Í£°ì¤ÎÌäÂê¤Ï¡¢¤³¤ì¤Ë¤è¤êºÇ½é¤Ë linked list ¤òºî¤ë¤Î¤Ë¤«¤«¤Ã¤¿°Ê¾å¤Ë »þ´Ö¤òÀáÌó¤Ç¤­¤ë¤«¤É¤¦¤«¤Ç¤¢¤ë¡£ Ãí°Õ:
¼Â¹Ô»þ¤Þ¤Ç·èÄê¤Ç¤­¤Ê¤¤Ê¸»úÎó¤ò¸¡º÷¤¹¤ë¾ì¹ç¤Ï¡¢ ¥ë¡¼¥×¤òÁ´Éôʸ»úÎó¤È¤·¤Æ¤½¤ì¤ò eval ¤¹¤ë¤³¤È¤Ç ²¿²ó¤âÁ´¥Ñ¥¿¡¼¥ó¤ò¥³¥ó¥Ñ¥¤¥ë¤·Ä¾¤¹¤Î¤òËɤ°¤³¤È¤¬¤Ç¤­¤ë¡£ ¤³¤ì¤È¹ç¤ï¤»¤Æ¡¢Á´¥Õ¥¡¥¤¥ë¤¬ 1 ¥ì¥³¡¼¥É¤Ë¤Ê¤ë¤è¤¦¤Ë $/ ¤ò undef ¤¹¤ë¤È¡¢ ÂçÊÑ®¤¯¡¢ÀìÍÑ¤Î¥×¥í¥°¥é¥à fgrep ¤è¤ê¤â®¤¤¤³¤È¤¬Â¿¤¤¡£ °Ê²¼¤ÎÎã¤Ç¤Ï ¥Õ¥¡¥¤¥ë·²(@files) ¤«¤éñ¸ì·²(@words) ¤ò¸¡º÷¤·¡¢ ¥Þ¥Ã¥Á¤¹¤ë¥Õ¥¡¥¤¥ë¤Î̾Á°¤ò½ÐÎϤ¹¤ë¡£
$search = 'while (<>) { study;';
foreach $word (@words) {
    $search .= "++\$seen{\$ARGV} if /\\b$word\\b/;\n";
}
$search .= "}";
@ARGV = @files;
undef $/;
eval $search;       # ¤³¤ì¤ÏÂçÊÑ(this screams)
$/ = "\n";          # Ä̾ï¤Î delimiter ¤ËÌ᤹
foreach $file (sort keys(%seen)) {
    print $file, "\n";
}

tr/¸¡º÷¥ê¥¹¥È/ÃÖ´¹¥ê¥¹¥È/

`tr/SEARCHLIST/REPLACEMENTLIST/cds'
`y/SEARCHLIST/REPLACEMENTLIST/cds'
SEARCHLIST ¤Ë»ØÄꤷ¤¿Á´¤Æ¤Îʸ»ú¤ò¡¢REPLACEMENTLIST ¤Ë¤·¤¿¤¬¤Ã¤ÆÊÑ´¹¤¹¤ë¡£ ÃÖ´¹¤â¤·¤¯¤Ïºï½ü¤·¤¿Ê¸»ú¿ô¤òÊÖ¤¹¡£ =~ ¤ä !~ ¤ò»È¤Ã¤Æʸ»úÎó¤ò»ØÄꤷ¤Ê¤«¤Ã¤¿¾ì¹ç¤Ï¡¢ $_ ʸ»úÎó¤¬ÊÑ´¹¤µ¤ì¤ë¡£ (=~ ¤ò»È¤Ã¤Æ»ØÄꤹ¤ëʸ»úÎó¤Ï¥¹¥«¥é¡¼ÊÑ¿ô¡¢ÇÛÎó¤Î 1 Í×ÁÇ¡¢ ¤Þ¤¿¤Ï¤³¤ì¤é¤Ø¤ÎÂåÆþ¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£Â¨¤Á¡¢º¸ÊÕÃÍ¡£) sed ¿®¼Ô¤Î¤¿¤á¤Ë¡¢y ¤â tr ¤ÎÊÌ̾¤È¤·¤Æ¤¢¤ë¡£ SEARCHLIST ¤¬³ç¸ÌÎà¤Ç°Ï¤Þ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢ REPLACEMENTLIST ¤Ë¤Ï¤½¤ìÍѤζèÀÚ¤ê¤Î¥Ú¥¢¤ò»ØÄꤹ¤ë¤¬¡¢ ¤½¤ì¤Ï³ç¸ÌÎà¤Ç¤¢¤Ã¤Æ¤â¤Ê¤¯¤Æ¤â¤è¤¤¡£ Îã: tr[A-Z][a-z] ¤ä tr(+-*/)/ABCD/¡£ ½¤¾þ»Ò d ¤òÍѤ¤¤ë¤È¡¢ REPLACEMENTLIST ¤Ï¾ï¤Ë»ØÄꤷ¤¿¤½¤Î¤â¤Î¤È¤·¤Æ²ò¼á¤µ¤ì¤ë¡£ ¤½¤ì°Ê³°¤Î¾ì¹ç¤Ç¡¢ REPLACEMENTLIST ¤¬ SEARCHLIST ¤è¤ê¤âû¤¤¾ì¹ç¤Ï¡¢ Ʊ¤¸Ä¹¤µ¤Ë¤Ê¤ë¤Þ¤ÇºÇ¸å¤Îʸ»ú¤¬·«¤êÊÖ¤µ¤ì¤ë¡£ REPLACEMENTLIST ¤¬¥Ì¥ë¤Î¾ì¹ç¤Ï¡¢SEACHLIST ¤¬¥³¥Ô¡¼¤µ¤ì¤ë¡£ ¤³¤Î¸å¼Ô¤Ï¡¢¤¢¤ë¥¯¥é¥¹¤Ë´Þ¤Þ¤ì¤ëʸ»ú¤ò¥«¥¦¥ó¥È¤·¤¿¤ê¡¢ ¤¢¤ë¥¯¥é¥¹¤Îʸ»ú¤ÎϢ³¤ò½Ì¤á¤¿¤ê¤¹¤ë¤Î¤ËÊØÍø¤Ç¤¢¤ë¡£
$ARGV[1] =~ y/A-Z/a-z/;   # ¾®Ê¸»ú¤ËÅý°ì¤¹¤ë

$cnt = tr/*/*/;           # $_ Æâ¤Î * ¤ò¿ô¤¨¤ë

$cnt = tr/0-9//;          # $_ Æâ¤Î¿ô»ú¤ò¿ô¤¨¤ë

tr/a-zA-Z//s;             # bookkeeper -> bokeper

($HOST = $host) =~ tr/a-z/A-Z/;

y/a-zA-Z/ /cs;            # ¥¢¥ë¥Õ¥¡¥Ù¥Ã¥È°Ê³°¤ò 1 ʸ»ú¤Î¥¹¥Ú¡¼¥¹¤ËÃÖ´¹

tr/\200-\377/\0-\177/;    # 8 ¥Ó¥Ã¥ÈÌܤò¾Ã¤¹

y/¸¡º÷¥ê¥¹¥È/ÃÖ´¹¥ê¥¹¥È/

`y/SEARCHLIST/REPLACEMENT/'
tr/¸¡º÷¥ê¥¹¥È/ÃÖ´¹¥ê¥¹¥È/ ¤ÈƱ¤¸¡£Á°¹à¤ò»²¾È¡£

¥·¥¹¥Æ¥à´Ø¿ô

alarm

`alarm(SECONDS)'
`alarm SECONDS'
»ØÄꤷ¤¿Éÿô(¼ÂºÝ¤Ï 1 ¤ò°ú¤¤¤¿¤â¤Î)¤¬·Ð²á¤·¤¿¸å¡¢ SIGALRM ¤ò¥×¥í¥»¥¹¤ËÅÁ¤¨¤ë¡£ ¤Ä¤Þ¤ê¡¢ `alarm(15)' ¤Ï¤½¤ì¤«¤é 14 Éðʾå·Ð¤Ã¤¿¤¢¤ë»þÅÀ¤Ç SIGALRM ¤òµ¯¤³¤¹¡£ Ʊ»þ¤Ë¤Ï°ì¤Ä¤Î¥¿¥¤¥Þ¡¼¤·¤«¥«¥¦¥ó¥È¤Ç¤­¤Ê¤¤¡£ ¥³¡¼¥ë¤¹¤ëÅÙ¤ËÁ°¤Î¥¿¥¤¥Þ¡¼¤ò»È¤¨¤Ê¤¯¤¹¤ë¤·¡¢ ¤Þ¤¿°ú¿ô¤È¤·¤Æ 0 ¤òÍ¿¤¨¤ë¤È ¿·¤·¤¤¥¿¥¤¥Þ¡¼¤ò³«»Ï¤»¤º¤ËÁ°¤Î¥¿¥¤¥Þ¡¼¤ò¥­¥ã¥ó¥»¥ë¤¹¤ë¡£ ÊÖ¤êÃͤÏÁ°¤Î¥¿¥¤¥Þ¡¼¤Ë»Ä¤Ã¤Æ¤¤¤¿»þ´Ö¤Ç¤¢¤ë¡£

chdir

`chdir(EXPR)'
`chdir EXPR'
À®¸ù¤Ê¤é 1¡¢¼ºÇԤʤé 0¡£EXPR ¾Êά»þ¤Ï¥Û¡¼¥à¥Ç¥£¥ì¥¯¥È¥ê¡£

chroot

`chroot(FILENAME)'
`chroot FILENAME'
Ʊ̾¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤ÈƱ¤¸¡£ À®¸ù/¼ºÇԤˤè¤ê true/false ¤¬Ê֤롣 FILENAME ¤¬¾Êά¤µ¤ì¤¿¾ì¹ç¡¢$_ ¤Ë chroot ¤¹¤ë¡£

die

`die(LIST)'
`die LIST'
eval ¤Î³°¤Ç¤Ï¡¢LIST ¤ÎÃͤò STDERR ¤Ë½ÐÎϤ·¡¢ ¸½ºß¤Î $!(errno) ¤Ç exit ¤¹¤ë¡£ ¤â¤· $! ¤¬ 0 ¤Ê¤é¡¢ ($? >> 8 ) (`command` ¤Î¥¹¥Æ¡¼¥¿¥¹) ¤Ç exit ¤¹¤ë¡£ ¤â¤· ($? >> 8 ) ¤¬ 0 ¤Ê¤é¡¢255 ¤Ç exit ¤¹¤ë¡£ eval ¤ÎÃæ¤Ç¤Ï¡¢¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤¬ $@ ¤ËÆþ¤ê¡¢ eval ¤¬ undefined value ¤Ç½ªÎ»¤¹¤ë¡£
die "Can't cd to spool: $!\n"
    unless chdir '/usr/spool/news';

chdir '/usr/spool/news' || die "Can't cd to spool: $!\n"
EXPR ¤ÎÃͤ¬²þ¹Ô¤Ç½ª¤ï¤é¤Ê¤¤¾ì¹ç¤Ï¡¢ ¥¹¥¯¥ê¥×¥È¤Î¸½ºß¤Î¹ÔÈֹ椪¤è¤Ó(¤â¤·¤¢¤ì¤Ð)ÆþÎϹÔÈÖ¹æ¤âɽ¼¨¤µ¤ì¡¢ ²þ¹Ô¤¬ÉÕ¤±²Ã¤¨¤é¤ì¤ë¡£ ¥Ò¥ó¥È: ¥á¥Ã¥»¡¼¥¸¤Ë `, stopped' ¤òÉÕ¤±²Ã¤¨¤Æ¤ª¤¯¤È¡¢ `at foo line 123' ¤¬ÉÕ¤±²Ã¤¨¤é¤ì¤¿»þ¤Ë¤è¤ê¤ï¤«¤ê¤ä¤¹¤¤¡£
die "/etc/games is no good";
die "/etc/games is no good, stopped";
¤Ï¤½¤ì¤¾¤ì¼¡¤Î¤è¤¦¤Ë½ÐÎϤ¹¤ë¡£
/etc/games is no good at canasta line 123.
/etc/games is no good, stopped at canasta line 123.
See section exit.

exec

`exec(LIST)'
`exec LIST'
LIST ¤ÎÃæ¤Ë 1 °Ê¾å¤Î°ú¿ô¤¬¤¢¤ë¾ì¹ç¡¢ ¤Þ¤¿¤Ï LIST ¤¬ 1 °Ê¾å¤ÎÃͤò»ý¤ÄÇÛÎó¤Î¾ì¹ç¡¢ LIST Ãæ¤Î°ú¿ô¤Ç execvp() ¤ò¥³¡¼¥ë¤¹¤ë¡£ ¥¹¥«¥é¡¼°ú¿ô¤¬ 1 ¤·¤«¤Ê¤¤¾ì¹ç¡¢ °ú¿ô¤Ë¥·¥§¥ë¤Î¥á¥¿¥­¥ã¥é¥¯¥¿¡¼¤¬¤¢¤ë¤«¤É¤¦¤«¥Á¥§¥Ã¥¯¤µ¤ì¤ë¡£ ¤â¤·¤¢¤ì¤Ð¡¢parse ¤¹¤ë¤¿¤á¤ËÁ´°ú¿ô¤¬ `/bin/sh -c' ¤ËÅϤµ¤ì¤ë¡£ ¤â¤·¤Ê¤±¤ì¤Ð¡¢°ú¿ô¤Ïñ¸ìËè¤Ëʬ¤±¤é¤ì¡¢execvp() ¤Ë¤½¤Î¤Þ¤ÞÅϤµ¤ì¤ë¡£ ¤³¤ÎÊý¤¬¸úΨŪ¤À¤«¤é¤Ç¤¢¤ë¡£ Ãí°Õ:
exec(¤ª¤è¤Ó system)¤Ï½ÐÎϥХåե¡¤ò¥Õ¥é¥Ã¥·¥å¤·¤Ê¤¤¤Î¤Ç¡¢ ½ÐÎϤò¼º¤ï¤Ê¤¤¤¿¤á¤Ë $| ¤ò¥»¥Ã¥È¤¹¤ëɬÍפ¬¤¢¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
exec '/bin/echo', 'Your arguments are: ', @ARGV;
exec "sort $outfile | uniq";
ËÜÅö¤ÏÂè°ì°ú¿ô¤ò¼Â¹Ô¤·¤¿¤¯¤Ê¤¤¤¬¡¢ ¥×¥í¥°¥é¥à¤ò¤À¤Þ¤·¤Æ¤½¤Î̾Á°¤Ç¼Â¹Ô¤·¤Æ¤¤¤ë¤è¤¦¤Ë¸«¤»¤¿¤¤»þ¤Ï¡¢ ËÜÅö¤ËÁö¤é¤»¤¿¤¤¥×¥í¥°¥é¥à̾¤òÊÑ¿ô¤ËÂåÆþ¤·¡¢ ¤½¤ÎÊÑ¿ô¤ò LIST ¤ÎÁ°¤Ë¥³¥ó¥Þ¤È¶¦¤Ë»ØÄꤹ¤ì¤ÐÎɤ¤ (¤³¤¦¤¹¤ë¤È LIST ¤Ë¥¹¥«¥é¡¼¤¬°ì¤Ä¤·¤«¤Ê¤¯¤Æ¤â¡¢ LIST ¤¬¾ï¤ËÊ£¿ô¤ÎÃͤò»ý¤Ã¤Æ¤¤¤ë¤È²ò¼á¤µ¤ì¤ë)¡£
$shell = '/bin/csh';
exec $shell '-sh';       # ¥í¥°¥¤¥ó¥·¥§¥ë¤Î¤Õ¤ê¤ò¤¹¤ë

exit

`exit(EXPR)'
`exit EXPR'
EXPR ¤òɾ²Á¤·¡¢¤½¤ÎÃͤÇľÀÜ exit ¤¹¤ë¡£
        $ans = <STDIN>;
        exit 0 if $ans =~ /^[Xx]/;
EXPR ¤ò¾Êά¤¹¤ë¤È¡¢status 0 ¤Ç exit ¤¹¤ë¡£ See section die.

fork

`fork'
fork() ¥³¡¼¥ë¤ò¹Ô¤¦¡£¿Æ¥×¥í¥»¥¹¤Ë¤Ï»Ò¶¡¤Î¥×¥í¥»¥¹ ID ¤òÊÖ¤·¡¢ »Ò¥×¥í¥»¥¹¤Ë¤Ï 0 ¤òÊÖ¤¹¡£ Ãí°Õ:
ξÊý¤Î¥×¥í¥»¥¹¤Ë¤ª¤¤¤Æ¥Õ¥é¥Ã¥·¥å¤µ¤ì¤Æ¤¤¤Ê¤¤¥Ð¥Ã¥Õ¥¡¤Ï ¥Õ¥é¥Ã¥·¥å¤µ¤ì¤º¤Ë»Ä¤ë¤Î¤Ç¡¢ ¤À¤Ö¤Ã¤Æ½ÐÎϤµ¤ì¤ë¤Î¤òËɤ°¤Ë¤Ï¡¢ $| ¤ò¥»¥Ã¥È¤¹¤ëɬÍפ¬¤¢¤ë¡£ See section @hbox{@hbox to 1.6em{@tt@$|@hfil} : write ¤Þ¤¿¤Ï print ¤Î¸å¤Ë¥Õ¥é¥Ã¥·¥å¤ò¹Ô¤¦¤«Èݤ«}.

getlogin

`getlogin'
(¤â¤·¤¢¤ì¤Ð)`/etc/utmp' ¤«¤é¡¢¸½ºß¤Î login ¤òÆɤó¤ÇÊÖ¤¹¡£ ¥Ì¥ë¤Î¾ì¹ç¤Ï¡¢getpwuid ¤ò»È¤¦¤³¤È¡£
$login = getlogin || (getpwuid($<))[0] || "Somebody";
getpwuid ¤Ë¤Ä¤¤¤Æ¤Ï See section ¥·¥¹¥Æ¥à¥Õ¥¡¥¤¥ë¤«¤é¥Ç¡¼¥¿¤òÆÀ¤ë´Ø¿ô.

getpgrp

`getpgrp(PID)'
`getpgrp PID'
»ØÄꤷ¤¿ PID ¤Î¥×¥í¥»¥¹¥°¥ë¡¼¥×¤òÊÖ¤¹¡£ getpgrp(2) ¤ò¥¤¥ó¥×¥ê¥á¥ó¥È¤·¤Æ¤¤¤Ê¤¤¥Þ¥·¥ó¤Ç»ÈÍѤ¹¤ë¤È Ã×̿Ū¥¨¥é¡¼¤È¤Ê¤ë¡£ EXPR ¤ò¾Êά¤¹¤ë¤È¡¢¸½¥×¥í¥»¥¹¤Î¥×¥í¥»¥¹¥°¥ë¡¼¥×¤òÊÖ¤¹¡£

getppid

`getppid'
¿Æ¥×¥í¥»¥¹¤Î¥×¥í¥»¥¹ ID ¤òÊÖ¤¹¡£

getpriority

`getpriority(WHICH,WHO)'
¥×¥í¥»¥¹¡¢¥×¥í¥»¥¹¥°¥ë¡¼¥×¡¢¤Þ¤¿¤Ï¥æ¡¼¥¶¤Î¸½ºß¤Î¥×¥é¥¤¥ª¥ê¥Æ¥£¤òÊÖ¤¹¡£ (getpriority(2) ¤ò»²¾È¤Î¤³¤È¡£) getpriority(2) ¤ò¥¤¥ó¥×¥ê¥á¥ó¥È¤·¤Æ¤¤¤Ê¤¤¥Þ¥·¥ó¤Ç»ÈÍѤ¹¤ë¤È Ã×̿Ū¥¨¥é¡¼¤È¤Ê¤ë¡£

kill

`kill(LIST)'
`kill LIST'
¥ê¥¹¥È¤Ç¼¨¤µ¤ì¤ë¥×¥í¥»¥¹¤Ë¥·¥°¥Ê¥ë¤òÁ÷¤ë¡£ ¥ê¥¹¥È¤ÎÂè°ìÍ×ÁǤÏÁ÷¤ë¤Ù¤­¥·¥°¥Ê¥ë¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£ ¥·¥°¥Ê¥ëÁ÷¿®¤ËÀ®¸ù¤·¤¿¥×¥í¥»¥¹¤Î¿ô¤òÊÖ¤¹¡£
$cnt = kill 1, $child1, $child2;
kill 9, @goners;
¥·¥°¥Ê¥ë¤¬Éé¤Î¾ì¹ç¡¢¥×¥í¥»¥¹¤Ç¤Ï¤Ê¤¯¥×¥í¥»¥¹¥°¥ë¡¼¥×¤ò kill ¤¹¤ë¡£ (System V ¤Ç¤Ï¡¢ Éé¤Î¥×¥í¥»¥¹ÈÖ¹æ¤Ï¥×¥í¥»¥¹¥°¥ë¡¼¥×¤â kill ¤¹¤ë¤¬¡¢¸ß´¹À­¤Ï¤Ê¤¤¡£) ¥·¥°¥Ê¥ë̾¤ò»ØÄꤷ¤Æ¤â¤è¤¤¡£

setpgrp

`setpgrp(PID,PGRP)'
¥«¥ì¥ó¥È¥×¥í¥»¥¹¥°¥ë¡¼¥×¤ò»ØÄꤷ¤¿ÃÍ PID ¤Ë¥»¥Ã¥È¤·¡¢ ¥«¥ì¥ó¥È¥×¥í¥»¥¹¤ò 0 ¤Ë¤¹¤ë¡£ setpgrp(2) ¤ò¥¤¥ó¥×¥ê¥á¥ó¥È¤·¤Æ¤¤¤Ê¤¤¥Þ¥·¥ó¤Ç¤ÏÃ×̿Ū¥¨¥é¡¼¤È¤Ê¤ë¡£

setpriority

`setpriority(WHICH,WHO,PRIORITY)'
¤¢¤ë¥×¥í¥»¥¹¡¢¥×¥í¥»¥¹¥°¥ë¡¼¥×¡¢ ¤Þ¤¿¤Ï¥æ¡¼¥¶¤Î¥«¥ì¥ó¥È¥×¥é¥¤¥ª¥ê¥Æ¥£¤ò¥»¥Ã¥È¤¹¤ë¡£ setpriority(2) ¤ò¥¤¥ó¥×¥ê¥á¥ó¥È¤·¤Æ¤¤¤Ê¤¤¥Þ¥·¥ó¤Ç¤Ï Ã×̿Ū¥¨¥é¡¼¤È¤Ê¤ë¡£ (setpriority(2) ¤ò»²¾È¡£)

sleep

`sleep(EXPR)'
`sleep EXPR'
`sleep'
EXPR ÉäδÖ(EXPR ¤ò¾Êά¤¹¤ë¤È¡¢±Êµ×¤Ë)¥¹¥¯¥ê¥×¥È¤òÄä»ß¤¹¤ë¡£ ¥×¥í¥»¥¹¤Ë SIGALRM ¤òÁ÷¤ë¤È interrupt ¤Ç¤­¤ë¤À¤í¤¦¡£ ¼ÂºÝ¤ËÄä»ß¤·¤¿»þ´Ö¤òÊÖ¤¹¡£ ¤ª¤½¤é¤¯ alarm ¤È sleep ¤òº®ºß¤µ¤»¤ë¤³¤È¤Ï¤Ç¤­¤Ê¤¤¤À¤í¤¦¡£ sleep() ¤Ï alarm() ¤òÍѤ¤¤Æ¥¤¥ó¥×¥ê¥á¥ó¥È¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¤¬ ¿¤¤¤«¤é¤À¡£

syscall

`syscall(LIST)'
`syscall LIST'
LIST ¤ÎºÇ½é¤ÎÍ×ÁǤǻØÄꤹ¤ë¥·¥¹¥Æ¥à¥³¡¼¥ë¤ò¹Ô¤¦¡£ »Ä¤ê¤ÎÍ×ÁǤϥ·¥¹¥Æ¥à¥³¡¼¥ë¤Î°ú¿ô¤È¤·¤ÆÅϤµ¤ì¤ë¡£ ¥¤¥ó¥×¥ê¥á¥ó¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤ÏÃ×̿Ū¥¨¥é¡¼¤È¤Ê¤ë¡£ °ú¿ô¤Ï°Ê²¼¤Î¤è¤¦¤Ë²ò¼á¤µ¤ì¤ë¡£ ʸ»úÎó¤Ë½ñ¤­¹þ¤Þ¤ì¤ë¤É¤ó¤Ê·ë²Ì¤Ç¤â¼õ¤±¼è¤ì¤ë¤è¤¦¤Ë¡¢ ʸ»úÎó¤ÎŤµ¤ò½¼Ê¬¼è¤ë¤Î¤Ï¥×¥í¥°¥é¥Þ¤ÎÀÕǤ¤Ç¤¢¤ë¡£ À°¿ô¤Î°ú¿ô¤¬¿ô»ú¤Ç¤Ï¤Ê¤¯¡¢¿ô¤Ç¤¢¤ë¤È¤¤¤¦¥³¥ó¥Æ¥­¥¹¥È¤Ç²ò¼á¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¡¢ ¿ô¤Ç¤¢¤ë¤³¤È¤ò¼¨¤¹¤¿¤á¤Ë 0 ¤ò­¤¹É¬Íפ¬¤¢¤ë¤À¤í¤¦¡£
require 'syscall.ph'; # h2ph ¤ÎɬÍפ¬¤¢¤ë¤«¤â¤·¤ì¤Ê¤¤
syscall(&SYS_write, fileno(STDOUT), "hi there\n", 9);

system

`system(LIST)'
`system LIST'
`exec LIST' ¤ÈÁ´¤¯Æ±¤¸¤³¤È¤ò¤¹¤ë¤¬¡¢ °ã¤¤¤ÏºÇ½é¤Ë fork ¤ò¹Ô¤¤¡¢ ¿Æ¥×¥í¥»¥¹¤Ï»Ò¥×¥í¥»¥¹¤¬´°Î»¤¹¤ë¤Î¤òÂÔ¤ÄÅÀ¤Ç¤¢¤ë¡£ Ãí°Õ: °ú¿ô¤Î½èÍý¤Ï°ú¿ô¤Î¿ô¤Ë¤è¤Ã¤ÆÊѤï¤ë¡£ ÊÖ¤êÃÍ¤Ï¥×¥í¥°¥é¥à¤Î exit status ¤Ç¡¢wait() ¤ÈƱ¤¸¤Ç¤¢¤ë¡£
¼ÂºÝ¤Î exit value ¤òÆÀ¤ë¤Ë¤Ï¡¢256 ¤Ç³ä¤ëɬÍפ¬¤¢¤ë¡£ See section exec.

times

`times'
¸½ºß¤Î¥×¥í¥»¥¹¤ª¤è¤Ó»Ò¥×¥í¥»¥¹¤Î¥æ¡¼¥¶¡¢ ¥·¥¹¥Æ¥à¥¿¥¤¥à(ÉÃ)¤ò»ý¤Ä 4 Í×ÁǤÎÇÛÎó¤òÊÖ¤¹¡£
($user,$system,$cuser,$csystem) = times;

umask

`umask(EXPR)'
`umask EXPR'
`umask'
¥×¥í¥»¥¹¤Î umask ¤ò¥»¥Ã¥È¤·¡¢Êѹ¹Á°¤ÎÃͤòÊÖ¤¹¡£ EXPR ¤ò¾Êά¤¹¤ë¤È¡¢¸½ºß¤ÎÃͤòÊÖ¤¹¤À¤±¤Ç¤¢¤ë¡£

wait

`wait'
»Ò¥×¥í¥»¥¹¤¬½ªÎ»¤¹¤ë¤Î¤òÂÔ¤Á¡¢ »à¤ó¤À¥×¥í¥»¥¹¤Î PID¡¢¤Þ¤¿¤Ï»Ò¥×¥í¥»¥¹¤¬¤Ê¤¤»þ¤Ï -1 ¤òÊÖ¤¹¡£ status ¤Ï $? ¤ËÊ֤롣See section waitpid.

waitpid

`waitpid(PID,FLAGS)'
¤¢¤ë»Ò¥×¥í¥»¥¹¤¬½ªÎ»¤¹¤ë¤Î¤òÂÔ¤Á¡¢ »à¤ó¤À¥×¥í¥»¥¹¤Î pid ¤òÊÖ¤¹¡£ ¤½¤Î¤è¤¦¤Ê»Ò¥×¥í¥»¥¹¤¬¤Ê¤±¤ì¤Ð¡¢-1 ¤òÊÖ¤¹¡£ ¥¹¥Æ¡¼¥¿¥¹¤Ï $? ¤ËÊ֤롣¼¡¤Î¤è¤¦¤Ê¥³¡¼¥É¤ò¼Â¹Ô¤¹¤ë¤È¡¢
require "sys/wait.h";
...
waitpid(-1,&WNOHANG);
¤É¤ó¤Ê¥×¥í¥»¥¹¤ËÂФ·¤Æ¤â non-blocking wait ¤ò¼Â¹Ô¤Ç¤­¤ë¡£ non-blocking wait ¤Ï waitpid(2) ¤Þ¤¿¤Ï wait4(2) ¤Î ¤É¤Á¤é¤«¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤ë¥Þ¥·¥ó¤Ç¤Î¤ß¼Â¹Ô²Äǽ¤Ç¤¢¤ë¡£ ¤·¤«¤·¡¢FLAGS ¤ò 0 ¤Ë¤·¤Æ¡¢¤¢¤ë pid ¤ò wait ¤¹¤ë¤Î¤Ï ¤É¤³¤Ç¤Ç¤â¥¤¥ó¥×¥ê¥á¥ó¥È¤µ¤ì¤Æ¤¤¤ë¡£(perl ¤Ï¡¢ exit ¤·¤¿¤¬¤Þ¤À perl ¥¹¥¯¥ê¥×¥È¤¬¼è¤êÆþ¤ì(harvest)¤·¤Æ¤¤¤Ê¤¤¥×¥í¥»¥¹¤Î ¥¹¥Æ¡¼¥¿¥¹Ãͤò³Ð¤¨¤Æ¤ª¤¯¤³¤È¤Ç¡¢¥·¥¹¥Æ¥à¥³¡¼¥ë¤Î¥¨¥ß¥å¥ì¡¼¥È¤ò¤¹¤ë¡£)

warn

`warn(LIST)'
`warn LIST'
`die' ¤Î¤è¤¦¤Ë¥á¥Ã¥»¡¼¥¸¤ò STDERR ¤Ë½Ð¤¹¤¬¡¢exit ¤·¤Ê¤¤¡£

¥Í¥Ã¥È¥ï¡¼¥¯´Ø¿ô

accept

`accept(NEWSOCKET,GENERICSOCKET)'
Ʊ̾¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤ÈƱ¤¸¡£À®¸ù/¼ºÇԤˤè¤ê true/false ¤¬Ê֤롣

bind

`bind(SOCKET,NAME)'
Ʊ̾¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤ÈƱ¤¸¡£À®¸ù/¼ºÇԤˤè¤ê true/false ¤¬Ê֤롣

connect

`connect(SOCKET,NAME)'
Ʊ̾¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤ÈƱ¤¸¤³¤È¤ò¤¹¤ë¡£ À®¸ù¤¹¤ì¤Ð¿¿¤ò¡¢¤½¤¦¤Ç¤Ê¤±¤ì¤Ðµ¶¤òÊÖ¤¹¡£ NAME ¤Ï¥½¥±¥Ã¥È¤ËŬÀڤʷ¿¤Î¥Ñ¥Ã¥±¡¼¥¸¥¢¥É¥ì¥¹¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£ ¥×¥í¥»¥¹´ÖÄÌ¿®¤Î¾Ï¤ÎÎã¤ò»²¾È¤Î¤³¤È¡£ See section ¥×¥í¥»¥¹´ÖÄÌ¿®.

getpeername

`getpeername(SOCKET)'
SOCKET ¥³¥Í¥¯¥·¥ç¥ó¤Î ¤â¤¦°ìÊý¤Î¥Ñ¥Ã¥¯¤µ¤ì¤¿ sockaddr ¥¢¥É¥ì¥¹¤òÊÖ¤¹¡£
# ¥¤¥ó¥¿¡¼¥Í¥Ã¥È¥½¥±¥Ã¥È¥¢¥É¥ì¥¹
$sockaddr = 'S n a4 x8';
$hersockaddr = getpeername(S);
($family, $port, $heraddr) =
        unpack($sockaddr,$hersockaddr);

getsockname

`getsockname(SOCKET)'
SOCKET ¥³¥Í¥¯¥·¥ç¥ó¤Î ¤³¤Á¤é¦¤Î¥Ñ¥Ã¥¯¤µ¤ì¤¿ sockaddr ¥¢¥É¥ì¥¹¤òÊÖ¤¹¡£
# ¥¤¥ó¥¿¡¼¥Í¥Ã¥È¥½¥±¥Ã¥È¥¢¥É¥ì¥¹
$sockaddr = 'S n a4 x8';
$mysockaddr = getsockname(S);
($family, $port, $myaddr) =
        unpack($sockaddr,$mysockaddr);

getsockopt

`getsockopt(SOCKET,LEVEL,OPTNAME)'
¥ê¥¯¥¨¥¹¥È¤µ¤ì¤¿¥½¥±¥Ã¥È¥ª¥×¥·¥ç¥ó¤òÊÖ¤¹¡£ ¥¨¥é¡¼¤¬¤¢¤ë¾ì¹ç¤Ë¤Ï undefined ¤¬Ê֤롣

listen

`listen(SOCKET,QUEUESIZE)'
listen ¥·¥¹¥Æ¥à¥³¡¼¥ë¤ÈƱ¤¸¤³¤È¤ò¤¹¤ë¡£ À®¸ù¤¹¤ì¤Ð¿¿¡¢¤½¤¦¤Ç¤Ê¤±¤ì¤Ðµ¶¤òÊÖ¤¹¡£¥×¥í¥»¥¹´ÖÄÌ¿®¤Î¾Ï¤ÎÎã¤ò»²¾È¡£ See section ¥×¥í¥»¥¹´ÖÄÌ¿®.

recv

`recv(SOCKET,SCALAR,LEN,FLAGS)'
¥½¥±¥Ã¥È¤«¤é¥á¥Ã¥»¡¼¥¸¤ò¼õ¤±¼è¤ë¡£ ¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë SOCKET ¤«¤é LENGTH ¥Ð¥¤¥È¤Î¥Ç¡¼¥¿¤ò¼õ¤±¼è¤ê¡¢ SCALAR ¤Ë³ÊǼ¤¹¤ë¡£ sender ¤Î¥¢¥É¥ì¥¹¤òÊÖ¤¹¡£¥¨¥é¡¼¤¬¤¢¤ë¤È¡¢undefined value ¤òÊÖ¤¹¡£ SCALAR ¤Ï¼ÂºÝ¤ËÆɤ߹þ¤ó¤À¥Ð¥¤¥È¿ô¤Ë¹ç¤ï¤»¤Æ¥µ¥¤¥º¤¬ÊѤï¤ë¡£ Ʊ̾¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤ÈƱ¤¸¥Õ¥é¥°¤òÍѤ¤¤ë¡£

send

`send(SOCKET,MSG,FLAGS,TO)'
`send(SOCKET,MSG,FLAGS)'
SOCKET ¤Ë¥á¥Ã¥»¡¼¥¸¤òÁ÷¤ë¡£Æ±Ì¾¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤ÈƱ¤¸¥Õ¥é¥°¤ò»È¤¦¡£ ¥³¥Í¥¯¥È¤·¤Æ¤¤¤Ê¤¤¥½¥±¥Ã¥È¤ËÂФ·¤Æ¤Ï¡¢ ¥á¥Ã¥»¡¼¥¸¤òÁ÷¤ëÁ÷¤êÀè TO ¤ò»ØÄꤷ¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£ Á÷¤Ã¤¿Ê¸»ú¿ô¤òÊÖ¤¹¡£¥¨¥é¡¼¤¬¤¢¤Ã¤¿¾ì¹ç¤Ï undefined ¤òÊÖ¤¹¡£

setsockopt

`setsockopt(SOCKET,LEVEL,OPTNAME,OPTVAL)'
¥ê¥¯¥¨¥¹¥È¤µ¤ì¤¿¥½¥±¥Ã¥È¥ª¥×¥·¥ç¥ó¤ò¥»¥Ã¥È¤¹¤ë¡£ ¥¨¥é¡¼¤¬¤¢¤Ã¤¿¾ì¹ç¤Ë¤Ï undefined ¤òÊÖ¤¹¡£ °ú¿ô¤òÁ÷¤ê¤¿¤¯¤Ê¤¤»þ¤Ë¤Ï OPTVAL ¤Ë undef ¤ò»ØÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤ë¡£

shutdown

`shutdown(SOCKET,HOW)'
HOW ¤Ç¼¨¤¹ÊýË¡(manner)¤Ç¥½¥±¥Ã¥È¥³¥Í¥¯¥·¥ç¥ó¤ò¥·¥ã¥Ã¥È¥À¥¦¥ó¤¹¤ë¡£ HOW ¤ÏƱ̾¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤ÈƱ¤¸¤è¤¦¤Ë²ò¼á¤µ¤ì¤ë¡£

socket

`socket(SOCKET,DOMAIN,TYPE,PROTOCOL)'
»ØÄꤷ¤¿¼ïÎà¤Î¥½¥±¥Ã¥È¤ò¥ª¡¼¥×¥ó¤·¡¢ ¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë SOCKET ¤Ë·ë¤ÓÉÕ¤±¤ë¡£ DOMAIN¡¢TYPE¡¢PROTOCOL ¤Ë¤Ï Ʊ̾¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤ÈƱ¤¸¤â¤Î¤ò»ØÄꤹ¤ë¡£ perl ¥é¥¤¥Ö¥é¥ê¥Õ¥¡¥¤¥ë¤«¤é¼ê·Ú¤ËŬÀÚ¤ÊÃͤòÆÀ¤ë¤¿¤á¤Ë¤Ï¡¢ `sys/socket.h' ¤ËÂФ·¤Æ `h2ph' ¤òÁö¤é¤»¤ëɬÍפ¬¤¢¤ë¤«¤âÃΤì¤Ê¤¤¡£ À®¸ù¤¹¤ì¤Ð¿¿¤òÊÖ¤¹¡£¥×¥í¥»¥¹´ÖÄÌ¿®¤Î¾Ï¤ÎÎã¤ò»²¾È¡£ See section ¥×¥í¥»¥¹´ÖÄÌ¿®.

socketpair

`socketpair(SOCKET1,SOCKET2,DOMAIN,TYPE,PROTOCOL)'
»ØÄꤷ¤¿ DOMAIN ¤Ë¡¢»ØÄꤷ¤¿ TYPE ¤Î̵̾¤Î¥½¥±¥Ã¥È¤Î¥Ú¥¢¤òºîÀ®¤¹¤ë¡£ DOMAIN¡¢TYPE¡¢PROTOCOL ¤ÏƱ̾¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤ÈƱ¤¸¤â¤Î¤ò»ØÄꤹ¤ë¡£ ¥¤¥ó¥×¥ê¥á¥ó¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¡¢Ã×̿Ū¥¨¥é¡¼¤È¤Ê¤ë¡£ À®¸ù¤¹¤ì¤Ð¿¿¤òÊÖ¤¹¡£

System V IPC ´Ø¿ô

msgctl

`msgctl(ID,CMD,ARG)'
System V IPC ´Ø¿ô msgctl ¤ò¸Æ¤Ö¡£ CMD ¤¬ &IPC_STAT ¤Ç¤¢¤ë¾ì¹ç¤Ï¡¢ ARG ¤ÏÊÑ¿ô¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤º¡¢¤³¤ì¤Ë msqid_ds ¹½Â¤ÂΤ¬Ê֤äƤ¯¤ë¡£ ioctl ¤ÈƱÍͤÎÃͤòÊÖ¤¹¡£ ¤¹¤Ê¤ï¤Á¡¢¥¨¥é¡¼¤¬¤¢¤ì¤Ð undefined ¤ÎÃÍ¡¢¥¼¥í¤Î¾ì¹ç¤Ï `0 ¤À¤¬¿¿'¡¢ ¤½¤Î¾¤Î¾ì¹ç¤Ï¼ÂºÝ¤ÎÊÖ¤êÃͤ¬Ê֤롣

msgget

`msgget(KEY,FLAGS)'
System V IPC ´Ø¿ô msgget ¤ò¸Æ¤Ö¡£ ¥á¥Ã¥»¡¼¥¸¥­¥å¡¼ID ¤òÊÖ¤¹¡£¥¨¥é¡¼¤¬¤¢¤ì¤Ð undefined ¤ÎÃͤòÊÖ¤¹¡£

msgsnd

`msgsnd(ID,MSG,FLAGS)'
System V IPC ´Ø¿ô msgsnd ¤ò¸Æ¤Ó¡¢ ¥á¥Ã¥»¡¼¥¸¥­¥å¡¼¼±Ê̻Ҥ¬ ID ¤Ç¤¢¤ë¥á¥Ã¥»¡¼¥¸¤Ë¥á¥Ã¥»¡¼¥¸ MSG ¤òÁ÷¤ë¡£ MSG ¤Î»Ï¤Þ¤ê¤Ï¥á¥Ã¥»¡¼¥¸·¿¤¬ long integer ¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤ (¤³¤ì¤Ï `pack("L", $type)' ¤ÇºîÀ®¤Ç¤­¤ë)¡£ À®¸ù¤¹¤ì¤Ð¿¿¡¢¥¨¥é¡¼¤¬¤¢¤ì¤Ðµ¶¤òÊÖ¤¹¡£

msgrcv

`msgrcv(ID,VAR,SIZE,TYPE,FLAGS)'
System V IPC ´Ø¿ô msgrcv ¤ò¸Æ¤Ó¡¢ ¥á¥Ã¥»¡¼¥¸¥­¥å¡¼ ID ¤«¤é¤Î¥á¥Ã¥»¡¼¥¸¤ò¼õ¤±¼è¤Ã¤Æ ÊÑ¿ô VAR ¤ËºÇÂç¥á¥Ã¥»¡¼¥¸¥µ¥¤¥º SIZE ¤Ç³ÊǼ¤¹¤ë¡£ Ãí°Õ: ¥á¥Ã¥»¡¼¥¸¤ò¼õ¤±¼è¤Ã¤¿¾ì¹ç¡¢ ¥á¥Ã¥»¡¼¥¸·¿¤Ï VAR ¤Ë³ÊǼ¤·¤¿ºÇ½é¤Î¤â¤Î¤Ë¤Ê¤ë¡£ ¤Þ¤¿¡¢VAR ¤ÎºÇÂ祵¥¤¥º¤Ï SIZE + ¥á¥Ã¥»¡¼¥¸·¿¤Î¥µ¥¤¥º ¤Ë¤Ê¤ë¡£ À®¸ù¤¹¤ì¤Ð¿¿¤òÊÖ¤·¡¢¥¨¥é¡¼¤¬¤¢¤ì¤Ðµ¶¤òÊÖ¤¹¡£

semctl

`semctl(ID,SEMNUM,CMD,ARG)'
System V IPC ´Ø¿ô semctl ¤ò¸Æ¤Ö¡£ CMD ¤¬ &IPC_STAT ¤Þ¤¿¤Ï &GETALL ¤Ê¤é¡¢ ARG ¤ÏÊÑ¿ô¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤º¡¢ ¤³¤ì¤Ë semid_ds ¹½Â¤ÂΤޤ¿¤Ï¥»¥Þ¥Õ¥©ÃͤÎÇÛÎó¤¬Ê֤롣 ioctl ¤ÈƱÍͤÎÃͤòÊÖ¤¹¡£ ¤¹¤Ê¤ï¤Á¡¢¥¨¥é¡¼¤¬¤¢¤ì¤Ð undefined ¤ÎÃÍ¡¢¥¼¥í¤Î¾ì¹ç¤Ï `0 ¤À¤¬¿¿'¡¢ ¤½¤Î¾¤Î¾ì¹ç¤Ï¼ÂºÝ¤ÎÊÖ¤êÃͤ¬Ê֤롣

semget

`semget(KEY,NSEMS,SIZE,FLAGS)'
System V IPC ´Ø¿ô semget ¤ò¸Æ¤Ö¡£¥»¥Þ¥Õ¥© ID ¤òÊÖ¤¹¡£ ¥¨¥é¡¼¤Î¾ì¹ç¤Ï undefined ¤ÎÃͤòÊÖ¤¹¡£

semop

`semop(KEY,OPSTRING)'
System V IPC ´Ø¿ô semop ¤ò¸Æ¤Ö¡£ ¤³¤ì¤Ë¤è¤ê¡¢signaling¡¢waiting ¤Ê¤É¤Î¥»¥Þ¥Õ¥©½èÍý¤ò¹Ô¤¦¤³¤È¤¬¤Ç¤­¤ë¡£ OPSTRING ¤Ï¡¢ semop ¹½Â¤ÂΤÎÇÛÎó¤ò pack ¤·¤¿¤â¤Î¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£ semop ¹½Â¤ÂΤϡ¢ `pack("sss", $semnum, $semop, $semflag)'¤Çºî¤ë¤³¤È¤¬¤Ç¤­¤ë¡£ ¥»¥Þ¥Õ¥©½èÍý¤Î¿ô¤Ï OPSTRING ¤ÎŤµ¤Ç°ÅÌÛ¤ÎÆâ¤Ë»ØÄꤵ¤ì¤ë¡£ À®¸ù¤¹¤ì¤Ð¿¿¡¢¥¨¥é¡¼¤¬¤¢¤ì¤Ðµ¶¤òÊÖ¤¹¡£
Îã: ¼¡¤Î¥³¡¼¥É¤Ï¥»¥Þ¥Õ¥© ID $semid ¤Î¥»¥Þ¥Õ¥© $semnum ¤òÂԤġ£
$semop = pack("sss", $semnum, -1, 0);
die "Semaphore trouble: $!\n" unless semop($semid, $semop);
¥»¥Þ¥Õ¥©¤Ë¥·¥°¥Ê¥ë¤òÁ÷¤ë¤Ë¤Ï¡¢`-1' ¤ò `1' ¤ËÃÖ¤­´¹¤¨¤ì¤Ð¤è¤¤¡£

shmctl

`shmctl(ID,CMD,ARG)'
System V IPC ´Ø¿ô shmctl ¤ò¸Æ¤Ö¡£ CMD ¤¬ &IPC_STAT ¤Ç¤¢¤ë¾ì¹ç¤Ï¡¢ ARG ¤ÏÊÑ¿ô¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤º¡¢ ¤³¤ì¤Ë shmid_ds ¹½Â¤ÂΤ¬Ê֤äƤ¯¤ë¡£ ioctl ¤ÈƱÍͤÎÃͤòÊÖ¤¹¡£ ¤¹¤Ê¤ï¤Á¡¢¥¨¥é¡¼¤¬¤¢¤ì¤Ð undefined ¤ÎÃÍ¡¢¥¼¥í¤Î¾ì¹ç¤Ï `0 ¤À¤¬¿¿'¡¢ ¤½¤Î¾¤Î¾ì¹ç¤Ï¼ÂºÝ¤ÎÊÖ¤êÃͤ¬Ê֤롣

shmget

`shmget(KEY,SIZE,FLAGS)'
System V IPC ´Ø¿ô shmget ¤ò¸Æ¤Ö¡£¶¦Í­¥á¥â¥ê ID ¤òÊÖ¤¹¡£ ¥¨¥é¡¼¤¬¤¢¤ì¤Ð undefined ¤ÎÃͤòÊÖ¤¹¡£

shmread

shmwrite

`shmread(ID,VAR,POS,SIZE)'
`shmwrite(ID,STRING,POS,SIZE)'
System V ¶¦Í­¥á¥â¥ê¥»¥°¥á¥ó¥È ID ¤Ë¡¢ °ÌÃÖ POS ¤«¤é ¥µ¥¤¥º SIZE ¤Ë¤ï¤¿¤Ã¤Æ attach ¤·¡¢ copy in/out ¤·¡¢detach ¤¹¤ë¤³¤È¤ÇÆɤ߹þ¤ß/½ñ¤­¹þ¤ß¤ò¹Ô¤¦¡£ Æɤ߹þ¤ß¤ÎºÝ¤Ë¤Ï¡¢VAR ¤ÏÊÑ¿ô¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤º¡¢ Æɤ߹þ¤Þ¤ì¤ë¥Ç¡¼¥¿¤¬³ÊǼ¤µ¤ì¤ë¡£ STRING ¤¬Ã»¤¤¾ì¹ç¤Ï¡¢SIZE ¥Ð¥¤¥È¤òËþ¤¿¤¹¤¿¤á¥Ì¥ë¤¬½ñ¤«¤ì¤ë¡£ À®¸ù¤¹¤ì¤Ð¿¿¡¢¥¨¥é¡¼¤¬¤¢¤ì¤Ðµ¶¤òÊÖ¤¹¡£

¥·¥¹¥Æ¥à¥Õ¥¡¥¤¥ë¤«¤é¥Ç¡¼¥¿¤òÆÀ¤ë´Ø¿ô

°Ê²¼¤Î * ¤ÎÉôʬ¤Ë¤Ï¡¢³Æ¥·¥¹¥Æ¥à¥Õ¥¡¥¤¥ë¤ËÂбþ¤·¤Æ¡¢

/etc/passwd      ¢ª    pw
/etc/group       ¢ª    gr
/etc/hosts       ¢ª    host
/etc/networks    ¢ª    net
/etc/protocols   ¢ª    proto
/etc/services    ¢ª    serv

¤¬¤½¤ì¤¾¤ìÆþ¤ë¡£

¤³¤ì¤é¤Î¥ë¡¼¥Á¥ó¤Ï¥·¥¹¥Æ¥à¥é¥¤¥Ö¥é¥êÆâ¤ÎƱÍͤδؿô¤ÈƱ¤¸Æ°ºî¤ò¤¹¤ë¡£ ÇÛÎó¤Î¥³¥ó¥Æ¥­¥¹¥È¤Ë¤ª¤¤¤Æ get ¥ë¡¼¥Á¥ó¤¬ÊÖ¤¹Ãͤϰʲ¼¤ÎÄ̤ê¤Ç¤¢¤ë¡£

($name,$passwd,$uid,$gid,
   $quota,$comment,$gcos,$dir,$shell) = getpw...
($name,$passwd,$gid,$members) = getgr...
($name,$aliases,$addrtype,$length,@addrs) = gethost...
($name,$aliases,$addrtype,$net) = getnet...
($name,$aliases,$proto) = getproto...
($name,$aliases,$port,$proto) = getserv...

(¥¨¥ó¥È¥ê¤¬Â¸ºß¤·¤Ê¤±¤ì¤Ð¥Ì¥ë¥ê¥¹¥È¤¬Ê֤롣)

¥¹¥«¥é¡¼¥³¥ó¥Æ¥­¥¹¥È¤Ç¤Ï¡¢Ì¾Á°(name) ¤¬Ê֤롣 ̾Á°¤Ç¤Î»²¾È¤Î¾ì¹ç¤Ï¡¢¤½¤ì°Ê³°¤Î³Æ¼ï¤ÎÃͤ¬Ê֤롣 (¥¨¥ó¥È¥ê¤¬Â¸ºß¤·¤Ê¤±¤ì¤Ð undefined ¤¬Ê֤롣)Î㤨¤Ð:

$uid = getpwnam
$name = getpwuid
$name = getpwent
$gid = getgrnam
$name = getgrgid
$name = getgrent
¤Ê¤É¡£

getgr... ¤¬ÊÖ¤¹ÃÍ $members ¤Ï ¥°¥ë¡¼¥×¤Î¥á¥ó¥Ð¡¼¤Î¥í¥°¥¤¥ó̾¤Î¥ê¥¹¥È¤ò¥¹¥Ú¡¼¥¹¤Ç¶èÀڤ俤â¤Î¤Ç¤¢¤ë¡£

gethost... ´Ø¿ô¤Ë¤Ä¤¤¤Æ¤Ï¡¢ C ¤¬ h_errno ¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤ë¾ì¹ç¡¢ ¥³¡¼¥ë¤¬¼ºÇÔ¤¹¤ì¤Ð¤½¤ÎÃͤ¬ $? ¤ËÊ֤롣 ¥³¡¼¥ë¤¬À®¸ù¤·¤¿¾ì¹ç¡¢ÊÖ¤ëÃÍ @addrs ¤Ï Âбþ¤¹¤ë¥·¥¹¥Æ¥à¥é¥¤¥Ö¥é¥ê¤ò¥³¡¼¥ë¤·¤ÆÆÀ¤é¤ì¤ë raw address ¤Î¥ê¥¹¥È¤Ç¤¢¤ë¡£ Internet ¤Î domain ¤Ç¤Ï¡¢³Æ¥¢¥É¥ì¥¹¤ÏŤµ 4 ¥Ð¥¤¥È¤Ç¡¢ ¼¡¤Î¤è¤¦¤Ë¤·¤Æ unpack ¤Ç¤­¤ë¡£

($a,$b,$c,$d) = unpack('C4',$addr[0]);

¤½¤Î¾¤Î´Ø¿ô

caller

`caller(EXPR)'
`caller'
¥µ¥Ö¥ë¡¼¥Á¥ó¥³¡¼¥ë¤Î¸½ºß¤Î¥³¥ó¥Æ¥­¥¹¥È¤òÊÖ¤¹¡£
($package,$filename,$line) = caller;
EXPR ¤ò»ØÄꤹ¤ë¤È¡¢ ¥Ç¥Ð¥Ã¥¬¤¬¥¹¥¿¥Ã¥¯¥È¥ì¡¼¥¹¤ò½ÐÎϤ¹¤ë¤¿¤á¤Ë»ÈÍѤ¹¤ë¾ðÊó¤âÊÖ¤¹¡£ EXPR ¤ÎÃͤ¬¡¢ ¸½ºß¤Î¥µ¥Ö¥ë¡¼¥Á¥ó¤ÎÁ°¤Ë call ¥Õ¥ì¡¼¥à¤¬¤¤¤¯¤Ä¤¢¤ë¤«¤ò¼¨¤¹¡£

defined

`defined(EXPR)'
`defined EXPR'
º¸ÊÕÃÍ EXPR ¤¬¼ÂºÝ¤ÎÃͤò»ý¤Ä¤«¤É¤¦¤«¤ò¼¨¤¹ boolean ÃͤòÊÖ¤¹¡£ ¥Õ¥¡¥¤¥ë¤Î½ª¤ï¤ê¡¢½é´ü²½¤µ¤ì¤Æ¤¤¤Ê¤¤ÊÑ¿ô¡¢ ¥·¥¹¥Æ¥à¥¨¥é¡¼¤Ê¤É¤ÎÎ㳰Ū¤Ê¾õ¶·¤Ç¤Ï¡¢define ¤µ¤ì¤Æ¤¤¤Ê¤¤ÃͤòÊÖ¤¹Áàºî¤¬Â¿¤¤¡£ ¤³¤Î´Ø¿ô¤ÏËÜÅö¤Î¥Ì¥ëʸ»úÎó¤òÊÖ¤¹¤«¤âÃΤì¤Ê¤¤Áàºî¤Ë¤Ä¤¤¤Æ¡¢ define ¤µ¤ì¤Æ¤¤¤Ê¤¤¥Ì¥ëʸ»úÎó¤È define ¤µ¤ì¤Æ¤¤¤ë¥Ì¥ëʸ»úÎó¤ò¶èÊ̤·¤Æ¤¯¤ì¤ë (ÆäËÇÛÎó¤ÎÍ×ÁǤò»²¾È¤¹¤ëÁàºî¤Ë¤Ä¤¤¤Æ)¡£ ¤Þ¤¿¡¢ÇÛÎó¤ä¥µ¥Ö¥ë¡¼¥Á¥ó¤¬Â¸ºß¤¹¤ë¤«¤É¤¦¤«¥Á¥§¥Ã¥¯¤¹¤ë¤³¤È¤â¤Ç¤­¤ë¡£ ͽ¤á define ¤µ¤ì¤Æ¤¤¤Ê¤¤ÊÑ¿ô¤ò»ÈÍѤ·¤Æ¤â¡¢´üÂÔ¤µ¤ì¤¿Æ°ºî¤ÏÊݾڤµ¤ì¤Ê¤¤¡£
print if defined $switch{'D'};
print "$val\n" while defined($val = pop(@ary));
die "Can't readlink $sym: $!"
     unless defined($value = readlink $sym);
eval '@foo = ()' if defined(@foo);
die "No XYZ package defined" unless defined %_XYZ;
sub foo { defined &$bar ? &$bar(@_) : die "No bar"; }
See section undef.

dump

`dump LABEL'
¤¿¤À¤Á¤Ë¥³¥¢¥À¥ó¥×¤¹¤ë¡£ ¤½¤â¤½¤â¤³¤Îµ¡Ç½¤Ï¥³¥¢¥À¥ó¥×¤«¤é undump ¥×¥í¥°¥é¥à¤ò»È¤Ã¤Æ ¼Â¹Ô²Äǽ¤Ê¥Ð¥¤¥Ê¥ê(¥×¥í¥°¥é¥à¤ÎÀèƬ¤Ç¤¢¤é¤«¤¸¤áÊÑ¿ô¤¬½é´ü²½¤µ¤ì¤Æ¤¤¤ë)¤ò ºî¤ë¤³¤È¤¬¤Ç¤­¤ë¤è¤¦¤Ë¤·¤¿¤â¤Î¤Ç¤¢¤ë¡£ ¤Ç¤­¤¿¥Ð¥¤¥Ê¥ê¤ò¼Â¹Ô¤¹¤ë¤È `goto LABEL' ¤òºÇ½é¤Ë¼Â¹Ô¤¹¤ë (goto ¤¬¤â¤ÄÀ©¸Â¤ÏÁ´¤ÆŬÍѤµ¤ì¤ë)¡£ dump ¤Ï ¥³¥¢¥À¥ó¥×¤ò¤Ï¤µ¤ó¤À goto + ºÆ¥¹¥¿¡¼¥È ¤È¹Í¤¨¤ì¤Ð¤è¤¤¡£ LABEL ¤ò¾Êά¤¹¤ë¤È¡¢¥×¥í¥°¥é¥à¤ÎÀèƬ¤«¤éºÆ¥¹¥¿¡¼¥È¤¹¤ë¡£ ·Ù¹ð: dump ¤Î»þÅÀ¤Ç¥ª¡¼¥×¥ó¤µ¤ì¤Æ¤¤¤¿¥Õ¥¡¥¤¥ë¤Ï¤¹¤Ù¤Æ ¥×¥í¥°¥é¥à¤¬ºÆÀ¸¤·¤¿»þ¤Ë¤Ï¥ª¡¼¥×¥ó¤µ¤ì¤Ê¤¤ (perl ¤Î¦¤«¤é¤ß¤ë¤Èº®Í𤹤뤿¤á)¡£ -u ¥ª¥×¥·¥ç¥ó¤â»²¾È¤Î¤³¤È¡£ See section ¥³¥Þ¥ó¥É¥é¥¤¥ó¥ª¥×¥·¥ç¥ó.
#!/usr/bin/perl
require 'getopt.pl';
require 'stat.pl';
%days = (
    'Sun',1,
    'Mon',2,
    'Tue',3,
    'Wed',4,
    'Thu',5,
    'Fri',6,
    'Sat',7);

dump QUICKSTART if $ARGV[0] eq '-d';

QUICKSTART:
 do Getopt('f');

local

`local(LIST)'
¥ê¥¹¥È¥¢¥Ã¥×¤·¤¿ÊÑ¿ô¤ò¡¢ ³ç¸Ì¤Ç°Ï¤Þ¤ì¤¿ ¥Ö¥í¥Ã¥¯¡¦¥µ¥Ö¥ë¡¼¥Á¥ó¡¦eval¡¦do ¤Ë¥í¡¼¥«¥ë¤Ç¤¢¤ë¤ÈÀë¸À¤¹¤ë¡£¥ê¥¹¥ÈÃæ¤ÎÁ´Í×ÁǤϺ¸ÊÕÃͤǤʤ±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£ local ¤Ï LIST Ãæ¤ÎÊÑ¿ô¤ÎÃͤò¥¹¥¿¥Ã¥¯¤ËÊݸ¤·¡¢ ¥Ö¥í¥Ã¥¯¡¦¥µ¥Ö¥ë¡¼¥Á¥ó¡¦eval ¤«¤éÈ´¤±¤ë»þ¤Ë¸µ¤ËÌ᤹¡£ ¤³¤Î¤¿¤á¡¢¸Æ¤Ð¤ì¤¿¥µ¥Ö¥ë¡¼¥Á¥ó¤Ç¤Ï¥í¡¼¥«¥ëÊÑ¿ô¤Ï»²¾È¤Ç¤­¤ë¤¬¡¢ ¥°¥í¡¼¥Ð¥ë¤ÊÊÑ¿ô¤Ï»²¾È¤Ç¤­¤Ê¤¤¤³¤È¤Ë¤Ê¤ë¡£ LIST ¤Ï´õ˾¤Ë¤è¤êÃͤòÂåÆþ¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£ ¤³¤ì¤Ë¤è¤ê¥í¡¼¥«¥ëÊÑ¿ô¤ò½é´ü²½¤Ç¤­¤ë¡£ (¤¢¤ëÊÑ¿ô¤Ë¤Ä¤¤¤Æ½é´ü²½¤ò»Ø¼¨¤·¤Ê¤¤¾ì¹ç¡¢ÃÍ¤Ï undefined ¤ÇºîÀ®¤µ¤ì¤ë¡£) Ä̾¥µ¥Ö¥ë¡¼¥Á¥ó¤Ø¤Î¥Ñ¥é¥á¡¼¥¿¤Ë̾Á°¤òÉÕ¤±¤ë¤Î¤ËÍѤ¤¤ë¡£
sub RANGEVAL {
     local($min, $max, $thunk) = @_;
     local($result) = ";
     local($i);

     # $thunk ¤Ï $i ¤ò»²¾È¤¹¤ë¤È²¾Äꤷ¤Æ¤¤¤ë

     for ($i = $min; $i < $max; $i++) {
          $result .= eval $thunk;
     }

     $result;
}

if ($sw eq '-v') {
    # ¥°¥í¡¼¥Ð¥ë¤ÊÇÛÎó¤Ç¥í¡¼¥«¥ë¤ÊÇÛÎó¤ò½é´ü²½
    local(@ARGV) = @ARGV;
    unshift(@ARGV,'echo');
    system @ARGV;
}
# @ARGV ¤ÏÊݸ¤µ¤ì¤ë

# Ï¢ÁÛÇÛÎó¤Ë°ì»þŪ¤Ë¿ô»ú¤òÉղ乤ë
if ($base12) {
     # (Ãí°Õ: ¤³¤ì¤¬¸úΨ¤¬¤è¤¤¤ï¤±¤Ç¤Ï¤Ê¤¤!)
     local(%digits) = (%digits,'t',10,'e',11);
     do parse_num();
}
Ãí°Õ:
local() ¤Ï run-time ¥³¥Þ¥ó¥É¤Ç¤¢¤ê¡¢¥ë¡¼¥×¤Ç¤ÏËè²ó¼Â¹Ô¤µ¤ì¤ë¡£ ¤³¤Î¤¿¤á¥ë¡¼¥×¤«¤éÈ´¤±¤Æ²òÊü¤¹¤ë¤Þ¤Ç¡¢Ëè²ó¥¹¥¿¥Ã¥¯¤ò¾ÃÈñ¤¹¤ë¡£

q

`q/STRING/'
`qq/STRING/'
`qx/STRING/'
¤³¤ì¤é¤ÏËÜÅö¤Î´Ø¿ô¤Ç¤Ï¤Ê¤¯¡¢Ã±¤Ê¤ë¥·¥ó¥¿¥Ã¥¯¥¹¥·¥å¥¬¡¼¤Ç¤¢¤ê¡¢ °úÍѤ¹¤ëʸ»úÎó¤Ë ¤¿¤¯¤µ¤ó¤Î¥Ð¥Ã¥¯¥¹¥é¥Ã¥·¥å¤òÆþ¤ì¤Ê¤¯¤Æ¤â¤¹¤à¤è¤¦¤Ë¤¹¤ë¤¿¤á¤Î¤â¤Î¤Ç¤¢¤ë¡£ q ¤Ï°ìÈ̲½¤µ¤ì¤¿¥·¥ó¥°¥ë¥¯¥©¡¼¥È¤Ç¤¢¤ê¡¢ qq ¤Ï°ìÈ̲½¤µ¤ì¤¿¥À¥Ö¥ë¥¯¥©¡¼¥È¤Ç¤¢¤ë¡£ qx ¤Ï°ìÈ̲½¤µ¤ì¤¿¥Ð¥Ã¥¯¥¯¥©¡¼¥È¤Ç¤¢¤ë¡£ / ¤ÎÂå¤ï¤ê¤Ë ²þ¹Ô¤ò´Þ¤à¥¢¥ë¥Õ¥¡¥Ù¥Ã¥È¡¦¿ô»ú¤Ç¤Ê¤¤Ç¤°Õ¤Îʸ»ú¤ò delimiter ¤È¤·¤Æ»È¤¨¤ë¡£ delimiter ¤¬ ( ¤Þ¤¿¤Ï { ¤Î¾ì¹ç¤Ï¡¢ ºÇ¸å¤Î delimiter ¤ÏÂбþ¤¹¤ë )¡¢} ¤È¤Ê¤ë¡£ ( ) ¤ä } ¤¬Ê¸»úÎó¤ËËä¤á¹þ¤Þ¤ì¤ë¾ì¹ç¤Ï ½¾ÍèÄ̤ê¥Ð¥Ã¥¯¥¹¥é¥Ã¥·¥å¤ò¤Ä¤±¤ëɬÍפ¬¤¢¤ë¡£)
    $foo = q!I said, "You said, 'She said it.'"!;
    $bar = q('This is it.');
    $today = qx{ date };
    $_ .= qq
*** The previous line contains the naughty word "$&".\n
    if /(ibm|apple|awk)/;      # :-)

require

`require(EXPR)'
`require EXPR'
`require'
EXPR¡¢¤Þ¤¿¤Ï EXPR ¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤»þ¤Ï $_ ¤Ç¼¨¤µ¤ì¤ë ¥é¥¤¥Ö¥é¥ê¥Õ¥¡¥¤¥ë¤ò¥¤¥ó¥¯¥ë¡¼¥É¤¹¤ë¡£ ¼¡¤Î¥µ¥Ö¥ë¡¼¥Á¥ó¤ÈƱ¤¸°ÕÌ£¤¬¤¢¤ë¡£
sub require {
    local($filename) = @_;
    return 1 if $INC{$filename};
    local($realfilename,$result);
    ITER: {
     foreach $prefix (@INC) {
        $realfilename = "$prefix/$filename";
        if (-f $realfilename) {
        $result = do $realfilename;
        last ITER;
        }
     }
     die "Can't find $filename in \@INC";
    }
    die $@ if $@;
    die "$filename did not return true value" unless $result;
    $INC{$filename} = $realfilename;
    $result;
}
Ãí°Õ: Ʊ¤¸Ì¾Á°¤Ç¥Õ¥¡¥¤¥ë¤òÆóÅÙ¥¤¥ó¥¯¥ë¡¼¥É¤¹¤ë¤³¤È¤Ï¤Ê¤¤¡£½é´ü²½¥³¡¼¥É¤Î ¼Â¹Ô¤¬À®¸ù¤·¤¿¤³¤È¤ò¼¨¤¹¤¿¤á¡¢¥Õ¥¡¥¤¥ë¤ÏºÇ¸å¤Îʸ¤Ç true ¤òÊÖ¤µ¤Ê¤±¤ì¤Ð¤Ê ¤é¤Ê¤¤¡£¤½¤Î¤¿¤á¡¢¤³¤Î¤è¤¦¤Ê¥Õ¥¡¥¤¥ë¤Ï 1; ¤Ç½ª¤ï¤ë¤Î¤¬½¬´·¤Ç¤¢¤ë (¤½¤ì¤ò¤·¤Ê¤¯¤Æ¤â true ¤òÊÖ¤¹¤³¤È¤¬¤Ï¤Ã¤­¤ê¤·¤Æ¤¤¤Ê¤¤¤«¤®¤ê)¡£ See section {@tt@INC} : perl ¥¹¥¯¥ê¥×¥È¤òõ¤¹¾ì½ê¤Î¥ê¥¹¥È.

reset

`reset(EXPR)'
`reset EXPR'
`reset'
Ä̾¥ë¡¼¥×¤ÎºÇ¸å¤Î continue ¥Ö¥í¥Ã¥¯¤ÎÃæ¤Ç¡¢ ÊÑ¿ô¤ò clear ¤·¡¢?? ¸¡º÷¤ò¥ê¥»¥Ã¥È¤·¤Æ ºÆ¤Ó»ÈÍѲÄǽ¤Ë¤¹¤ë¤¿¤á¤ËÍѤ¤¤ë¡£ EXPR ¤Ïʸ»ú¤Î¥ê¥¹¥È¤È¤·¤Æ²ò¼á¤µ¤ì¤ë(¥Ï¥¤¥Õ¥ó¤ÏÈϰϤò¼¨¤¹)¡£ ¤³¤Îʸ»ú¤Î¤É¤ì¤«¤Ç»Ï¤Þ¤ëÊÑ¿ô¤ª¤è¤ÓÇÛÎó¤ÏÁ´¤Æ¸µ¤Î¾õÂ֤˥ꥻ¥Ã¥È¤µ¤ì¤ë¡£ EXPR ¤ò¾Êά¤¹¤ë¤È¡¢ one-match search (?pattern?)¤¬ match ¤ËºÆ¥ê¥»¥Ã¥È¤µ¤ì¤ë¡£ ¥«¥ì¥ó¥È¤Î¥Ñ¥Ã¥±¡¼¥¸Æâ¤ÎÊÑ¿ô¡¦¸¡º÷¤Î¤ß¤ò¥ê¥»¥Ã¥È¤¹¤ë¡£ ¾ï¤Ë 1 ¤òÊÖ¤¹¡£See section ?¥Ñ¥¿¡¼¥ó?.
reset 'X';      # reset all X variables
reset 'a-z';    # reset lower case variables
reset;          # just reset ?? searches
Ãí°Õ:
`A-Z' ¤Ç¥ê¥»¥Ã¥È¤¹¤ë¤Î¤Ï´«¤á¤é¤ì¤Ê¤¤¡£ ¤Ê¤¼¤Ê¤é¡¢ÇÛÎó ARGV ¤ä ENV ¤ÎÆâÍƤò¾Ã¤¹¤«¤é¤Ç¤¢¤ë¡£ dbm Ï¢ÁÛÇÛÎó¤ò¥ê¥»¥Ã¥È¤·¤Æ¤â dbm ¥Õ¥¡¥¤¥ë¤òÊѹ¹¤·¤Ê¤¤¡£ (¤¬¡¢perl ¤¬¥­¥ã¥Ã¥·¥å¤·¤¿Á´¥¨¥ó¥È¥ê¤ò¥Õ¥é¥Ã¥·¥å¤¹¤ì¤Ð¡¢Êѹ¹¤¹¤ë¡£ ¤³¤¦¤¹¤ì¤Ð¡¢dbm ¥Õ¥¡¥¤¥ë¤ò¶¦Í­¤·¤Æ¤¤¤ë»þ¤ËÊØÍø¤Ç¤¢¤ë¡£ ÊØÍø¤Ç¤Ê¤¤¤«¤âÃΤì¤Ê¤¤¤¬¡£)

scalar

`scalar(EXPR)'
EXPR ¤ò¶¯À©Åª¤Ë¥¹¥«¥é¡¼¤Î¥³¥ó¥Æ¥­¥¹¥È¤Ç²ò¼á¤µ¤»¡¢¤½¤ÎÃͤòÊÖ¤¹¡£

undef

`undef(EXPR)'
`undef EXPR'
`undef'
EXPR(º¸ÊÕÃͤǤʤ¯¤Æ¤Ï¤Ê¤é¤Ê¤¤)¤ÎÃͤò undef ¤¹¤ë¡£ ¥¹¥«¥é¡¼ÃÍ¡¢ÇÛÎó¡¢¥µ¥Ö¥ë¡¼¥Á¥ó̾(& ¤òÍѤ¤¤ë) ¤ËÂФ·¤Æ¤Î¤ßÍѤ¤¤ë¤³¤È¡£ (undef ¤Ï¤ª¤½¤é¤¯ÄêµÁ¤µ¤ì¤Æ¤¤¤ëÊÑ¿ô¤ä dbm ÇÛÎóÃͤο¤¯¤Ë¤Ä¤¤¤Æ ´üÂÔ¤¹¤ëÆ°ºî¤ò¤·¤Ê¤¤¤Ç¤¢¤í¤¦¡£) ¾ï¤Ë undefined value ¤òÊÖ¤¹¡£ EXPR ¤ò¾Êά¤·¤Æ¤âÎɤ¤¤¬¡¢¤³¤Î¾ì¹ç²¿¤â undefine ¤µ¤ì¤º¡¢ Î㤨¤Ð¥µ¥Ö¥ë¡¼¥Á¥ó¤«¤éÊÖ¤ë»þ¤Ë undefined value ¤òÆÀ¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
undef $foo;
undef $bar{'blurfl'};
undef @ary;
undef %assoc;
undef &mysub;
return (wantarray ? () : undef) if $they_blew_it;

wantarray

`wantarray'
¸½ºß¼Â¹ÔÃæ¤Î¥µ¥Ö¥ë¡¼¥Á¥ó¤Î¥³¥ó¥Æ¥­¥¹¥È¤¬ÇÛÎóÃͤòÍ׵ᤷ¤Æ¤¤¤ì¤Ð true ¤òÊÖ¤¹¡£ ¥³¥ó¥Æ¥­¥¹¥È¤¬¥¹¥«¥é¡¼¤òÍ׵ᤷ¤Æ¤¤¤ì¤Ð false ¤òÊÖ¤¹¡£
return wantarray ? () : undef;

Í¥ÀèÅÙ

perl ¤Î±é»»»Ò¤Î·ë¹çµ¬Â§¤ÈÍ¥ÀèÅ٤ϼ¡¤ÎÄ̤ê¤Ç¤¢¤ë¡£

Í¥ÀèÅÙ  ·ë¹çµ¬Â§        ±é»»»Ò

Ä㤤    ¤Ê¤·            print printf exec system sort reverse
                        chmod chown kill unlink utime die return
        º¸¤«¤é±¦        ,
        ±¦¤«¤éº¸        = += -= *= ¤Ê¤É
        ±¦¤«¤éº¸        ?:
        ¤Ê¤·            ..
        º¸¤«¤é±¦        ||
        º¸¤«¤é±¦        &&
        º¸¤«¤é±¦        | ^
        º¸¤«¤é±¦        &
        ¤Ê¤·            == != <=> eq ne cmp
        ¤Ê¤·            < > <= >= lt gt le ge
        ¤Ê¤·            chdir exit eval reset sleep rand umask
        ¤Ê¤·            -r -w -x ¤Ê¤É
        º¸¤«¤é±¦        << >>
        º¸¤«¤é±¦        + - .
        º¸¤«¤é±¦        * / % x
        º¸¤«¤é±¦        =~ !~
        ±¦¤«¤éº¸        ! ~ ¤ª¤è¤Óñ¹à±é»»»Ò -
        ±¦¤«¤éº¸        **
        ¤Ê¤·            ++ --
¹â¤¤    º¸¤«¤é±¦        '('

¥ê¥¹¥È¤ò°ú¿ô¤Ë¤È¤ë±é»»»Ò(print ¤½¤Î¾)¤ä ñ¹à±é»»»Ò¤¹¤Ù¤Æ(chdir ¤Ê¤É)¤Îľ¤°¸å¤í(Ʊ¤¸¹Ô)¤Ëº¸³ç¸Ì¤¬¤¢¤ë¾ì¹ç¡¢ Ä̾ï¤Î´Ø¿ô¸Æ¤Ó½Ð¤·¤ÈƱ¤¸¤è¤¦¤Ë±é»»»Ò¤È³ç¸Ì¤ÎÃæ¤Î°ú¿ô¤ÏºÇ¤â¹â¤¤Í¥ÀèÅÙ¤ò»ý¤Ä¡£

(Îã)

chdir $foo || die;       # (chdir $foo) || die
chdir($foo) || die;      # (chdir $foo) || die
chdir ($foo) || die;     # (chdir $foo) || die
chdir +($foo) || die;    # (chdir $foo) || die

¤·¤«¤·¡¢* ¤Ï || ¤è¤ê¤âÍ¥ÀèÅÙ¤¬¹â¤¤¤Î¤Ç¡¢

chdir $foo * 20;         # chdir ($foo * 20)
chdir($foo) * 20;        # (chdir $foo) * 20
chdir ($foo) * 20;       # (chdir $foo) * 20
chdir +($foo) * 20;      # chdir ($foo * 20)

rand 10 * 20;            # rand (10 * 20)
rand(10) * 20;           # (rand 10) * 20
rand (10) * 20;          # (rand 10) * 20
rand +(10) * 20;         # rand (10 * 20)

³ç¸Ì¤¬¤Ê¤¤¾ì¹ç¡¢print, sort, chmod ¤È¤¤¤Ã¤¿ ¥ê¥¹¥È¤ò°ú¿ô¤Ë»ý¤Ä±é»»»Ò¤ÎÍ¥ÀèÅÙ¤Ï ±é»»»Ò¤Îº¸Â¦¤ò¸«¤ë¤«±¦Â¦¤ò¸«¤ë¤«¤Ë¤è¤Ã¤ÆÈó¾ï¤Ë¹â¤¤¤«¡¢ Èó¾ï¤ËÄ㤤¤«¤Î¤É¤Á¤é¤«¤Ç¤¢¤ë¡£

¤¿¤È¤¨¤Ð¡¢¼¡¤ÎÎã¤Ç¡¢

@ary = (1, 3, sort 4, 2);
print @ary;         # prints 1324

sort ¤Î±¦Â¦¤Ë¤¢¤ë¥³¥ó¥Þ¤Ï sort ¤ÎÁ°¤Ëɾ²Á¤µ¤ì¤ë¤¬¡¢ º¸Â¦¤Î¥³¥ó¥Þ¤Ï sort ¤Î¸å¤Çɾ²Á¤µ¤ì¤ë¡£ ¸À¤¤´¹¤¨¤ë¤È¡¢¥ê¥¹¥È¤ò°ú¿ô¤Ë¼è¤ë±é»»»Ò¤Ï ¤½¤ì¤Ë³¤¯°ú¿ô¤ò¤¹¤Ù¤Æ¼«Ê¬¤Î¤â¤Î¤Ë¤·¤Æ¤·¤Þ¤¤¡¢ ¤½¤Î¸å¤ÏÁ°¤Ë¤¢¤ë expression ¤Ëñ½ã¤Ë½¾¤¦·¹¸þ¤¬¤¢¤ë¡£

³ç¸Ì¤Ë¤ÏÃí°Õ¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£

# ¤³¤ì¤é¤Ï print ¤òɾ²Á¤¹¤ëÁ°¤Ë exit ¤òɾ²Á¤·¤Æ¤·¤Þ¤¦
print($foo, exit);  # ÌÀ¤é¤«¤Ë¤³¤ì¤ÏÀµ¤·¤¯¤Ê¤¤
print $foo, exit;   # ¤³¤ì¤Ç¤â¤Ê¤¤

# ¤³¤ì¤é¤Ï exit ¤òɾ²Á¤¹¤ëÁ°¤Ë print ¤ò¼Â¹Ô¤¹¤ë
(print $foo), exit; # ¤³¤ì¤¬Àµ¤·¤¤
print($foo), exit;  # ¤Þ¤¿¤Ï¤³¤ì¡£
print ($foo), exit; # ¤³¤ì¤Ç¤âÀµ¤·¤¤¡£

¤Þ¤¿¡¢

print ($foo & 255) + 1, "\n";

¤Ï¤ª¤½¤é¤¯¸«¤¿ÌܤÎÆ°ºî¤Ï¤·¤Ê¤¤¡£

¥µ¥Ö¥ë¡¼¥Á¥ó

¥µ¥Ö¥ë¡¼¥Á¥ó¤Ï¼¡¤Î¤è¤¦¤ËÀë¸À¤¹¤ë¡£

        sub NAME BLOCK

ÅϤ·¤¿°ú¿ô¤ÏÁ´¤ÆÇÛÎó @_¡¢ ¤¹¤Ê¤ï¤Á $_[0], $_[1],... ¤ËÆþ¤ë¡£ ÇÛÎó @_ ¤Ï¥í¡¼¥«¥ë¤ÊÇÛÎó¤À¤¬¡¢ ¤½¤ÎÃͤϼºݤΥ¹¥«¥é¡¼¥Ñ¥é¥á¡¼¥¿¤Ø¤Î»²¾È¤È¤Ê¤Ã¤Æ¤¤¤ë¡£ ¥µ¥Ö¥ë¡¼¥Á¥ó¤ÎÊÖ¤êÃͤϺǸå¤Ëɾ²Á¤·¤¿ expression ¤ÎÃͤǤ¢¤ê¡¢ ÇÛÎóÃͤǤ⥹¥«¥é¡¼ÃͤǤâ¤è¤¤¡£ ¤Þ¤¿¡¢ÃͤòÊÖ¤·¤Æ¥µ¥Ö¥ë¡¼¥Á¥ó¤«¤éÈ´¤±¤ë¤³¤È¤ò»Ø¼¨¤¹¤ë¤¿¤á¤Ë¡¢ return Àë¸À¤ò»È¤Ã¤Æ¤â¤è¤¤¡£ ¥í¡¼¥«¥ëÊÑ¿ô¤òºî¤ëÊýË¡¤Ï¡¢local ±é»»»Ò¤Î¹à¤ò»²¾È¤Î¤³¤È¡£ See section local.

¥µ¥Ö¥ë¡¼¥Á¥ó¤Ï do ±é»»»Ò¤Þ¤¿¤Ï & ±é»»»Ò¤òÍѤ¤¤Æ¥³¡¼¥ë¤¹¤ë¡£

Îã:

sub MAX {
     local($max) = pop(@_);
     foreach $foo (@_) {
          $max = $foo if $max < $foo;
     }
     $max;
}

...
$bestday = &MAX($mon,$tue,$wed,$thu,$fri);

Îã:

# ¹Ô¤ò¼õ¤±¼è¤ê¡¢¥¹¥Ú¡¼¥¹Îà¤Ç»Ï¤Þ¤ë·Ñ³¹Ô¤ò·ë¹ç¤¹¤ë
sub get_line {
     $thisline = $lookahead;
     line: while ($lookahead = <STDIN>) {
        if ($lookahead =~ /^[ \t]/) {
             $thisline .= $lookahead;
        }
        else {
             last line;
        }
     }
     $thisline;
}

$lookahead = <STDIN>;    # ºÇ½é¤Î¹Ô¤òÆÀ¤ë
while ($_ = do get_line()) {
     ...
}

°ú¿ô¤Ë̾Á°¤ò¤Ä¤±¤ë¤Ë¤Ï¡¢¥í¡¼¥«¥ë¤Ê¥ê¥¹¥È¤ØÇÛÎóÂåÆþ¤ò¹Ô¤¦¡£

sub maybeset {
     local($key, $value) = @_;
     $foo{$key} = $value unless $foo{$key};
}

¤³¤¦¤¹¤ë¤³¤È¤Ç¡¢»²¾È¸Æ¤Ó½Ð¤·¤¬Ã͸ƤӽФ·¤Ë¤Ê¤ë¡£ ¤Ê¤¼¤Ê¤é¡¢ÂåÆþ¤Ë¤è¤êÃͤ¬¥³¥Ô¡¼¤µ¤ì¤ë¤«¤é¤Ç¤¢¤ë¡£

¥µ¥Ö¥ë¡¼¥Á¥ó¤ÏºÆµ¢Åª¤Ë¸Æ¤Ó½Ð¤·¤Æ¤â¤è¤¤¡£ ¥µ¥Ö¥ë¡¼¥Á¥ó¤ò & ·Á¼°¤Ç¸Æ¤Ó½Ð¤¹¾ì¹ç¤Ï°ú¿ô¤Î¥ê¥¹¥È¤Ï¤Ä¤±¤Ê¤¯¤Æ¤â¤è¤¤¡£ ¤³¤ì¤ò¾Êά¤¹¤ë¤È¡¢¥µ¥Ö¥ë¡¼¥Á¥ó¤ÎÇÛÎó @_ ¤Î¥»¥Ã¥È¥¢¥Ã¥×¤Ï¹Ô¤ï¤ì¤Ê¤¤¡£ ¥³¡¼¥ë¤ò¹Ô¤Ã¤¿»þ¤ÎÇÛÎó @_ ¤¬¥µ¥Ö¥ë¡¼¥Á¥ó¤«¤é»²¾È¤Ç¤­¤ë¡£

do foo(1,2,3);  # 3 ¤Ä¤Î°ú¿ô¤òÅϤ¹

&foo(1,2,3);    # Ʊ¤¸

do foo();       # ¥Ì¥ë¥ê¥¹¥È¤òÅϤ¹
&foo();         # Ʊ¤¸
&foo;           # °ú¿ô¤òÅϤµ¤Ê¤¤ -- ¤è¤ê¸úΨ¤¬¤è¤¤

»²¾ÈÅϤ·

¥µ¥Ö¥ë¡¼¥Á¥ó¤ØÇÛÎó¤ÎÃͤòÅϤ¹¤Î¤Ç¤Ï¤Ê¤¯¡¢ ¤½¤Î̾Á°¤òÅϤ·¤Æ¡¢¥µ¥Ö¥ë¡¼¥Á¥ó¤¬¥í¡¼¥«¥ë¤Ê¥³¥Ô¡¼¤ËÂФ·¤Æ¤Ç¤Ï¤Ê¤¯ ¥°¥í¡¼¥Ð¥ë¤ÊÇÛÎó¤òÊѹ¹¤Ç¤­¤ë¤è¤¦¤Ë¤·¤¿¤¤»þ¤¬¤¢¤ë¤À¤í¤¦¡£

perl ¤Ç¤Ï̾Á°¤ò»ý¤ÄÁ´¤Æ¤Î¥ª¥Ö¥¸¥§¥¯¥È¤ËÂФ·¤Æ¡¢ ¤½¤Î̾Á°¤ÎÁ°¤Ë * ¤ò¤Ä¤±¤ë¤³¤È¤Ç»²¾È¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë: *foo ¡£ ¤³¤ì¤¬É¾²Á¤µ¤ì¤ë¤È¡¢¤½¤Î̾Á°¤ò»ý¤Ä¡¢ ¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¡¦¥Õ¥©¡¼¥Þ¥Ã¥È¡¦¥µ¥Ö¥ë¡¼¥Á¥ó¤ò´Þ¤à Á´¥ª¥Ö¥¸¥§¥¯¥È¤òɽ¤¹¥¹¥«¥é¡¼ÃͤȤʤ롣 local() ±é»»Æâ¤ÇÂåÆþ¤ò¹Ô¤¦¤È¡¢ ¤½¤Î̾Á°¤¬¤½¤ì¤ËÂåÆþ¤µ¤ì¤¿ *ÃÍ ¤ò»²¾È¤¹¤ë¤è¤¦¤Ë¤Ê¤ë¡£Î㤨¤Ð¡¢

sub doubleary {
    local(*someary) = @_;
    foreach $elem (@someary) {
     $elem *= 2;
    }
}
do doubleary(*foo);
do doubleary(*bar);

*name ¤Ø¤ÎÂåÆþ¤Ï ¸½ºß¤Î¤È¤³¤í local() ¤Î¾ì¹ç¤·¤«¤ª´«¤á¤Ç¤­¤Ê¤¤¡£ ¼ÂºÝ¤Î¤È¤³¤í¡¢*name ¤Ø¤ÎÂåÆþ¤Ï¤É¤³¤Ç¤â¤Ç¤­¤ë¤Î¤À¤¬¡¢ °ÊÁ°¤Ë¹Ô¤Ã¤¿ *name ¤Ø¤Î»²¾È¤¬±Ê±ó¤ËÈø¤ò°ú¤¯(may be stranded forever) ²ÄǽÀ­¤¬¤¢¤ë¡£¤³¤ì¤Ïº¤¤Ã¤¿¤³¤È¤«¤â¤·¤ì¤Ê¤¤¤·¡¢¤½¤¦¤Ç¤Ê¤¤¤«¤â¤·¤ì¤Ê¤¤¡£

¥¹¥«¥é¡¼Ãͤϲ¿¤â¤·¤Ê¤¯¤Æ¤â»²¾ÈÅϤ·¤Ç¤¢¤ë¡£ ¤¹¤Ê¤ï¤Á¡¢¤³¤Î¥á¥«¥Ë¥º¥à¤òÍѤ¤¤Ê¤¯¤Æ¤â¡¢ ´Ø¿´¤Î¤¢¤ë $_[nnn] ¤Ø¤ÎÌÀ¼¨Åª¤Ê»²¾È¤ò¹Ô¤¦¤³¤È¤Ç Êѹ¹¤ò¹Ô¤¦¤³¤È¤¬²Äǽ¤Ç¤¢¤ë¡£ ÇÛÎó¤ÎÁ´Í×ÁǤò¥¹¥«¥é¡¼ÃͤȤ·¤ÆÅϤ¹¤³¤È¤ÇÇÛÎóÍ×ÁǤÎÊѹ¹¤Ï²Äǽ¤Ç¤¢¤ë¤¬¡¢ push¡¢pop ¤äÇÛÎó¤ÎÂ礭¤µ¤òÊѤ¨¤ëÁàºî¤Ë¤Ï¡¢ *¥á¥«¥Ë¥º¥à¤ò»È¤ï¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£ *¥á¥«¥Ë¥º¥à¤Ï¤É¤Î¤è¤¦¤Ê¾ì¹ç¤Ç¤â¸úΨ¤¬¤è¤ê¤è¤¤¤À¤í¤¦¡£

*name ¤ÎÃͤϽÐÎÏÉÔ²Äǽ¤Ê¥Ð¥¤¥Ê¥ê¥Ç¡¼¥¿¤ò´Þ¤à¤Î¤Ç¡¢ print ¤ä printf¡¢ sprintf ¤Î %s ¤Ø¤Î°ú¿ô¤È¤·¤ÆÍѤ¤¤ë¤È ½ÐÎϤò¤­¤ì¤¤¤Ë¹Ô¤¦¤¿¤á¡¢`*name' ¤È¤¤¤¦Ãͤˤʤ롣

ÇÛÎó¤òÊѹ¹¤·¤¿¤¯¤Ê¤¤¾ì¹ç¤Ç¤â¡¢ ¤³¤Î¥á¥«¥Ë¥º¥à¤ÏÊ£¿ô¤ÎÇÛÎó¤ò°ì¤Ä¤Î¥ê¥¹¥È¤ÇÅϤ¹¤Î¤ËÊØÍø¤Ç¤¢¤ë¡£ ¤Ê¤¼¤Ê¤é¡¢Ä̾¥ê¥¹¥È¥á¥«¥Ë¥º¥à¤ÏÁ´ÇÛÎóÃͤò°ì¤Ä¤Ë¥Þ¡¼¥¸¤¹¤ë¤¿¤á¡¢ ¤½¤ì¤ò¸Ä¡¹¤ÎÇÛÎó¤Ëʬ¤±¤ë¤³¤È¤¬¤Ç¤­¤Ê¤¤¤«¤é¤Ç¤¢¤ë¡£

Àµµ¬É½¸½

¥Ñ¥¿¡¼¥ó¥Þ¥Ã¥Á¥ó¥°¤ÇÍѤ¤¤é¤ì¤ë¥Ñ¥¿¡¼¥ó¤Ï¡¢ Version 8 ¤Î regexp ¥ë¡¼¥Á¥ó¤Ç»ÈÍѤǤ­¤ë¤â¤Î¤ÈƱ¤¸¤â¤Î¤Ç¤¢¤ë¡£ (¼Â¤Ï¡¢¥Ø¥ó¥ê¡¼¥¹¥Ú¥ó¥µ¡¼¤ÎºÆÇÛÉÛ¼«Í³¤Ê V8 ¥ë¡¼¥Á¥ó¤ò»È¤Ã¤Æ¤¤¤ë¡£)

¤³¤ì¤Ë²Ã¤¨¤Æ¡¢°Ê²¼¤Î¥Þ¥Ã¥Á¥ó¥°¤¬»È¤¨¤ë¡£

\w : ¥¢¥ë¥Õ¥¡¥Ù¥Ã¥Èʸ»ú( "_" ¤ò´Þ¤à)
\W : Èó¥¢¥ë¥Õ¥¡¥Ù¥Ã¥Èʸ»ú
\b : ñ¸ì¤Î¶­³¦
\B : Èóñ¸ì¶­³¦
\s : ¥¹¥Ú¡¼¥¹Ê¸»ú(whitespace character)
\S : Èó¥¹¥Ú¡¼¥¹Ê¸»ú
\d : ¿ô»ú
\D : Èó¿ô»ú

³ç¸Ì¹½Â¤ ( ... ) ¤ò»È¤¦¤È¡¢ \¿ô»ú¤¬¤½¤Î¿ô»úÈÖÌܤÎʸ»úÎó¤Ë¥Þ¥Ã¥Á¤¹¤ë¡£ (¥Ñ¥¿¡¼¥ó¤Î³°¤Ç¤Ï¡¢ ¿ô»ú¤ÎÁ°¤Ë \ ¤Ç¤Ï¤Ê¤¯ $ ¤ò¾ï¤ËÍѤ¤¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£ $¿ô»ú ¤È $`¡¢$&¡¢$' ¤ÎÍ­¸úÈÏ°Ï¤Ï ³ç¸Ì¤Ç°Ï¤Þ¤ì¤¿¥Ö¥í¥Ã¥¯¤ä eval ʸ»úÎó¡¢ ¤Þ¤¿¤Ï¼¡¤Î¥Ñ¥¿¡¼¥ó¥Þ¥Ã¥Á¤Þ¤Ç¤Ç¤¢¤ë¡£ \¿ô»ú µ­½Ò¤Ï¸½ºß¤Î¥Ñ¥¿¡¼¥ó¤Î³°¤Ç¤â»È¤¨¤ë¤³¤È¤¬¤¢¤ë¤¬¡¢ ¤½¤ì¤ËÍê¤ë¤Ù¤­¤Ç¤Ï¤Ê¤¤¡£) ³ç¸Ì¤Ï¤¤¤¯¤ÄÍѤ¤¤Æ¤â¤è¤¤¡£ 9 ¤è¤ê¿¤¯¤ÎÉôʬʸ»úÎ󤬤¢¤ë¾ì¹ç¤Ï¡¢ $10,$11... ¤¬Âбþ¤¹¤ëÉôʬʸ»úÎó¤ò»²¾È¤¹¤ë¡£ ¥Ñ¥¿¡¼¥ó¤ÎÃæ¤Ç¤Ï¡¢\10,\11 ... ¤¬Éôʬʸ»úÎó¤ò¸åÊý»²¾È¤¹¤ë (¾¯¤Ê¤¯¤È¤â¤½¤Î¿ô¤Îº¸³ç¸Ì¤¬¸åÊý»²¾È²Õ½ê¤ÎÁ°¤Ë¤¢¤ë¾ì¹ç¡£ ¤Ê¤±¤ì¤Ð°ÊÁ°¤Î¥Ð¡¼¥¸¥ç¥ó¤È¤Î¥³¥ó¥Ñ¥Á¥Ó¥ê¥Æ¥£¤Î¤¿¤á¡¢ \10 ¤Ï \010 ¤¹¤Ê¤ï¤Á¥Ð¥Ã¥¯¥¹¥Ú¡¼¥¹¤ÈƱ¤¸¡¢ \11 ¤Ï \011 ¤¹¤Ê¤ï¤Á¥¿¥Ö¤ÈƱ¤¸¡¢¤È¤Ê¤ë¡£ \1 ¤«¤é \9 ¤Þ¤Ç¤Ï¾ï¤Ë¸åÊý»²¾È¤Ç¤¢¤ë¡£)¡£

(Îã)

s/^([^ ]*) *([^ ]*)/$2 $1/;   # ºÇ½é¤Î 2 ñ¸ì¤òÆþ¤ìÂؤ¨¤ë

if (/Time: (..):(..):(..)/) {
        $hours = $1;
        $minutes = $2;
        $seconds = $3;
}

¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¡¢Ê¸»ú ^ ¤Ïʸ»úÎó¤ÎºÇ½é¤Î¤ß¡¢ ʸ»ú $ ¤Ïʸ»úÎó¤ÎºÇ¸å (¤Þ¤¿¤ÏºÇ¸å¤Î²þ¹Ôʸ»ú¤ÎÁ°¤Îʸ»ú)¤Î¤ß¤Ë°ìÃפ¹¤ë¤³¤È¤¬Êݾڤµ¤ì¤Æ¤¤¤Æ¡¢ ¤Þ¤¿¡¢perl ¤Ïʸ»úÎó¤¬ 1 ¹Ô¤·¤«´Þ¤ó¤Ç¤¤¤Ê¤¤¤È²¾Äꤷ¤ÆºÇŬ²½¤·¤Æ¤¤¤ë¡£ ²þ¹Ôʸ»ú¤¬Ê£¿ô¤¢¤ë¾ì¹ç¤Î ^ ¤È $ ¤ÎµóÆ°¤ÏÌ·½â¤¹¤ë (beinconsistent)¡£ ¤·¤«¤·¡¢Ê¸»úÎó¤òÊ£¿ô¹Ô¤Î¥Ð¥Ã¥Õ¥¡¤È¤·¤Æ°·¤¤¡¢ ^ ¤¬Ê¸»úÎóÃæ¤ÎÁ´¤Æ¤Î²þ¹Ôʸ»ú¤Î¸å¤Ë¥Þ¥Ã¥Á¤·¡¢ $ ¤¬Á´¤Æ¤Î²þ¹Ôʸ»ú¤ÎÁ°¤Ë¥Þ¥Ã¥Á¤¹¤ë¤è¤¦¤Ë¤·¤¿¤¤¾ì¹ç¤â¤¢¤ë¤À¤í¤¦¡£ ¤³¤ì¤ò¼Â¸½¤¹¤ë¤Ë¤Ï¡¢¾¯¤·¥ª¡¼¥Ð¡¼¥Ø¥Ã¥É¤òÍפ¹¤ë¤¬¡¢ $* ÊÑ¿ô¤Ë 1 ¤ò¥»¥Ã¥È¤¹¤ì¤ÐÎɤ¤¡£ ¤³¤ÎÊÑ¿ô¤ò 0 ¤ËÌ᤻¤Ð¡¢perl ¤ÏËÜÍè¤ÎµóÆ°¤ËÌá¤ë¡£See section @hbox{@hbox to 1.6em{@tt@$*@hfil} : Ê£¿ô¹Ô¥Ñ¥¿¡¼¥ó¥Þ¥Ã¥Á¥ó¥°¤ò¹Ô¤¦¤«Èݤ«}.

Ê£¿ô¹Ô¤ÎÃÖ´¹¤òÍưפˤ¹¤ë¤¿¤á¤Ë¡¢Ê¸»ú . ¤Ï²þ¹Ôʸ»ú¤Ë¥Þ¥Ã¥Á¤·¤Ê¤¤ ($* ¤¬ 0 ¤Î»þ¤Ç¤â)¡£Æäˡ¢¼¡¤ÎÎã¤Ç¤Ï¡¢$_ ¤Ë²þ¹Ôʸ»ú¤ò»Ä¤¹¡£

$_ = <STDIN>;
s/.*(some_string).*/$1/;

²þ¹Ôʸ»ú¤¬¤¤¤é¤Ê¤¤¤Ê¤é¡¢¼¡¤Î¤É¤ì¤«¤ò»î¤»¤ÐÎɤ¤¡£

s/.*(some_string).*\n/$1/;
s/.*(some_string)[^\000]*/$1/;
s/.*(some_string)(.|\n)*/$1/;
chop; s/.*(some_string).*/$1/;
/(some_string)/ && ($_ = $1);

Àµµ¬É½¸½¤Î³ÆÍ×ÁǤθå¤Ë¡¢ Ãæ³ç¸Ì¤Ç°Ï¤ó¤À¿ô»ú¤ò {n,m} ¤Î·Á¤ÇÉÕ¤±¤ë¤³¤È¤¬¤Ç¤­¤ë¡£ ¤³¤³¤Ç n ¤Ï¤½¤ÎÍ×ÁǤ˥ޥåÁ¤¹¤ëºÇ¾®¸Â¤Î²ó¿ô¡¢ m ¤ÏºÇÂç¸Â¤Î²ó¿ô¤òɽ¤¹¡£ {n} ¤Î·Á¤Ï {n,n} ¤ÈƱÅù¤Ç¤¢¤ê¡¢ n ²ó¤Á¤ç¤¦¤É¤Ë¥Þ¥Ã¥Á¤¹¤ë¡£

{n,} ¤Î·Á¤Ï n °Ê¾å¤Î²ó¿ô¤Ë¥Þ¥Ã¥Á¤¹¤ë (Ãæ³ç¸Ì¤¬Ê̤Υ³¥ó¥Æ¥­¥¹¥È¤Ç»È¤ï¤ì¤¿¾ì¹ç¤Ï¡¢Ãæ³ç¸Ì¤ÏÄ̾ï¤Îʸ»ú¤È¤·¤Æ°·¤ï¤ì¤ë)¡£

½¤¾þ»Ò * ¤Ï {0,}¡¢½¤¾þ»Ò + ¤Ï {1,}¡¢ ½¤¾þ»Ò ? ¤Ï {0,1}¤Ë¤½¤ì¤¾¤ìÅù¤·¤¤¡£

n ¤ä m ¤ÎÂ礭¤µ¤Ë¤ÏÀ©¸Â¤Ï¤Ê¤¤¤¬¡¢ Â礭¤Ê¿ô¤ò»È¤¦¤È¤è¤ê¿¤¯¤Î¥á¥â¥ê¡¼¤ò¾ÃÈñ¤¹¤ë¡£

perl ¤Ç¤Ï¡¢Î㤨¤Ð \b¡¢\w¡¢\n ¤Î¤è¤¦¤Ë¡¢ ¥Ð¥Ã¥¯¥¹¥é¥Ã¥·¥å¤òÁ°¤ËÉÕ¤±¤ë¥á¥¿¥­¥ã¥é¥¯¥¿¡¼¤Ï ¤¹¤Ù¤Æ¥¢¥ë¥Õ¥¡¥Ù¥Ã¥È¤Ç¤¢¤ë¤³¤È¤Ëµ¤¤¬¤Ä¤¯¤À¤í¤¦¡£

¾¤ÎÀµµ¬É½¸½¸À¸ì¤È°ã¤¤¡¢ ¥¢¥ë¥Õ¥¡¥Ù¥Ã¥È¤Ç¤Ê¤¤Ê¸»ú¤Ë¥Ð¥Ã¥¯¥¹¥é¥Ã¥·¥å¤ò¤Ä¤±¤ë¤³¤È¤Ï¤Ê¤¤¤Î¤Ç¡¢ \\¡¢ \(¡¢ \)¡¢ \<¡¢ \>¡¢ \{¡¢ ¤ä \} ¤Î¤è¤¦¤Ê¤â¤Î¤ÏÁ´¤Æʸ»úÄ̤ê¤Ë²ò¼á¤µ¤ì¡¢ ¥á¥¿¥­¥ã¥é¥¯¥¿¡¼¤È¤Ï²ò¼á¤µ¤ì¤Ê¤¤¡£ ¤³¤ì¤Ë¤è¤ê¡¢¥á¥¿¥­¥ã¥é¥¯¥¿¡¼¤ò´Þ¤ó¤Ç¤¤¤ë¤Î¤Ç¤Ï¤Ê¤¤¤«¤È¿´ÇÛ¤Êʸ»úÎó¤ò ¥Ñ¥¿¡¼¥ó¤È¤·¤Æ»ÈÍѤ¹¤ë¤³¤È¤¬Íưפˤʤ롣 ¥¢¥ë¥Õ¥¡¥Ù¥Ã¥È¤Ç¤Ê¤¤Ê¸»ú¤Ïñ½ã¤Ë»ÈÍѤ·¤ÆÎɤ¤¡£

$pattern =~ s/(\W)/\\$1/g;

¥Õ¥©¡¼¥Þ¥Ã¥È

write ±é»»»Ò¤Ç»È¤¦½ÐÎϥ쥳¡¼¥É¥Õ¥©¡¼¥Þ¥Ã¥È¤Ï°Ê²¼¤Î¤è¤¦¤ËÀë¸À¤¹¤ë¡£

format NAME =
FORMLIST
.

NAME ¤ò¾Êά¤¹¤ë¤È¡¢`STDOUT' ¤¬ÄêµÁ¤µ¤ì¤ë¡£ FORMLIST ¤ÏÊ£¿ô¹Ô¤«¤é¤Ê¤ê¡¢¹Ô¤Ï¤½¤ì¤¾¤ì 3 ¼ïÎà¤Î¤É¤ì¤«¤Ç¤¢¤ë¡£

  1. ¥³¥á¥ó¥È
  2. 1 ½ÐÎϹԤΥե©¡¼¥Þ¥Ã¥È¤ò¼¨¤¹ `picture' ¹Ô¡£
  3. `picture' ¹Ô¤ËÃͤòÍ¿¤¨¤ë°ú¿ô¹Ô¡£

picture ¹Ô¤Ï¹ÔÆâ¤ÎÃͤ¬ÃÖ´¹¤µ¤ì¤ëÆÃÄê¤Î¥Õ¥£¡¼¥ë¥É¤ò½ü¤¤¤Æ ¸«¤¿Ìܤ½¤Î¤Þ¤Þ¤Ë½ÐÎϤµ¤ì¤ë¡£ picture ¥Õ¥£¡¼¥ë¥É¤ÏÁ´¤Æ @ ¤Þ¤¿¤Ï ^ ¤Ç»Ï¤Þ¤ë¡£ @ ¥Õ¥£¡¼¥ë¥É(ÇÛÎó¤òɽ¤¹ @ ¤Èº®Í𤷤ʤ¤¤è¤¦¤Ë)¤ÏÄ̾ï¤Î¾ì¹ç¡¢ ^ ¥Õ¥£¡¼¥ë¥É¤ÏÊ£¿ô¹Ô¥Æ¥­¥¹¥È¥Ö¥í¥Ã¥¯¤Î ½éÊâŪ¤Ê filling ¤ò¹Ô¤¦¤¿¤á¤Î¤â¤Î¤Ç¤¢¤ë¡£

¥Õ¥£¡¼¥ë¥É¤ÎŤµ¤Ïʸ»ú < > | ¤ÇËä¤á¤ë¤³¤È¤Çɽ¤¹¡£ ¤³¤ì¤é¤Ï¤½¤ì¤¾¤ìº¸´ó¤»¡¢±¦´ó¤»¡¢¥»¥ó¥¿¥ê¥ó¥°¤ò»Ø¼¨¤¹¤ë¡£ ±¦´ó¤»¤Ë¤Ä¤¤¤Æ¤Ï¡¢#(¤Ë . ¤ò¤Ä¤±¤Æ¤â¤è¤¤)¤ò»È¤Ã¤Æ ¿ôÃÍ¥Õ¥£¡¼¥ë¥É¤Ç¤¢¤ë¤³¤È¤ò»ØÄꤷ¤Æ¤â¤è¤¤¡£ (@ ¤ÎÂå¤ï¤ê¤Ë ^ ¤ò»È¤¦¤È¡¢¤½¤Î¥Õ¥£¡¼¥ë¥É¤¬ undefined ¤Î¾ì¹ç¥Ö¥é¥ó¥¯¤Ë¤Ê¤ë¡£)

¤³¤ì¤é¤Î¥Õ¥£¡¼¥ë¥É¤Ë»ØÄꤵ¤ì¤¿Ãͤ˲þ¹Ô¤¬Æþ¤Ã¤Æ¤¤¤ë¾ì¹ç¤Ï¡¢ ²þ¹Ô¤Þ¤Ç¤Î¥Æ¥­¥¹¥È¤Î¤ß¤¬½ÐÎϤµ¤ì¤ë¡£ Æüì¤Ê¥Õ¥£¡¼¥ë¥É @* ¤ÏÊ£¿ô¹Ô¤ÎÃͤò½ÐÎϤ¹¤ë¤Î¤ËÍѤ¤¤ë¡£ ¤³¤ì¤Ï°ì¹Ô¤Ë¤½¤ì¤À¤±¤·¤«»ØÄê¤Ç¤­¤Ê¤¤¡£

ÃͤϤ½¤Î¼¡¤Î¹Ô¤Ç»ØÄꤹ¤ë¡£ ½çÈÖ¤Ï picture ¥Õ¥£¡¼¥ë¥É¤Î¤â¤Î¤ÈƱ¤¸¤Ë¤¹¤ë¡£ Ãͤϥ³¥ó¥Þ¤Ç¶èÀÚ¤é¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£

@ ¤Ç¤Ï¤Ê¤¯¡¢ ^ ¤Ç»Ï¤Þ¤ë picture ¥Õ¥£¡¼¥ë¥É¤ÏÆÃÊ̤˰·¤ï¤ì¤ë¡£ »ØÄꤹ¤ëÃͤϥƥ­¥¹¥Èʸ»úÎó¤òÃͤȤ·¤Æ»ý¤Ä¥¹¥«¥é¡¼ÊÑ¿ô¤Î̾Á°¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£ perl ¤Ï²Äǽ¤Ê¤«¤®¤ê¤Î¥Æ¥­¥¹¥È¤ò¥Õ¥£¡¼¥ë¥É¤ËÍ¿¤¨¡¢ÊÑ¿ô¤ÎÀèƬ¤«¤é¤½¤ì¤ò¼è¤ê½ü¤¯¡£ ¤³¤ì¤Ï¼¡¤Ë¤½¤ÎÊÑ¿ô¤¬»²¾È¤µ¤ì¤¿»þ¤Ë¥Æ¥­¥¹¥È¤Î³¤­¤òɽ¼¨¤¹¤ë¤¿¤á¤Ç¤¢¤ë¡£ Ä̾¥Æ¥­¥¹¥È¥Ö¥í¥Ã¥¯¤ò½ÐÎϤ¹¤ë¤Ë¤Ï¿âľ¤Ê¥¹¥¿¥Ã¥¯¤ÎÃæ¤Ë¥Õ¥£¡¼¥ë¥É¤ò¤¤¤¯¤Ä¤«½ñ¤¯¡£

ºÇ¸å¤Î¥Õ¥£¡¼¥ë¥É¤ò ... ¤Ç½ª¤ï¤ë¤³¤È¤â¤Ç¤­¤ë¡£ ¤³¤¦¤¹¤ì¤Ð¥Æ¥­¥¹¥È¤¬Á´ÉôÆþ¤ê¤­¤é¤Ê¤¤¾ì¹ç¤Ë ... ¤¬½ÐÎϤ˸½¤ì¤ë¡£ ÊÑ¿ô $: ¤ò¹¥¤ß¤Îʸ»ú¤Î¥ê¥¹¥È¤ËÊѹ¹¤¹¤ë¤³¤È¤Ç ¥Æ¥­¥¹¥È¤òʬ³ä¤¹¤ë¤³¤È¤¬²Äǽ¤Êʸ»ú¤òÊѤ¨¤ë¤³¤È¤¬¤Ç¤­¤ë¡£ See section @hbox{@hbox to 1.6em{@tt@$:@hfil} : format ¤Çʸ»úÎó¤òʬ¤±¤ëºÝ¤ÎľÁ°¤Îʸ»úÎ󥻥åÈ}.

¥Õ¥©¡¼¥Þ¥Ã¥È¤µ¤ì¤ë¥Æ¥­¥¹¥È¤¬Ã»¤¤¾ì¹ç¡¢ ^ ¥Õ¥£¡¼¥ë¥É¤ò»È¤¦¤È²ÄÊÑĹ¥ì¥³¡¼¥É¤¬¤Ç¤­¤ë¤Î¤Ç¡¢ ¹Ô¤Î¤É¤³¤«¤Ëʸ»ú ~ ¤òÆþ¤ì¤ë¤³¤È¤Ç¶õ¹Ô¤Î½ÐÎϤòÍÞÀ©¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£ (¸«°×¤µ¤ò¹Í¤¨¤ë¤È¡¢Ä̾²Äǽ¤Ê¤é¤ÐÀèƬ¤ËÆþ¤ì¤ë¤Ù¤­¤Ç¤¢¤ë¡£)

~ ¤Ï½ÐÎϤˤª¤¤¤Æ¥¹¥Ú¡¼¥¹¤ËÊÑ´¹¤µ¤ì¤ë¡£ °ì¤ÄÌܤ˳¤±¤ÆÆó¤ÄÌܤΠ~ ¤òÆþ¤ì¤ë¤È¡¢ ¹ÔÃæ¤ÎÁ´¥Õ¥£¡¼¥ë¥É¤¬¤Ê¤¯¤Ê¤ë¤Þ¤Ç¤½¤Î¹Ô¤ò·«¤êÊÖ¤¹?¡£ (@ ¥Õ¥£¡¼¥ë¥É¤ò»È¤¦¾ì¹ç¡¢¤½¤ì¤ËÍ¿¤¨¤ë expression ¤Ï ±Ê±ó¤ËƱ¤¸ÃͤǤ¢¤ë¤è¤¦¤Ê¤â¤Î¤Ë¤¹¤ë¤Ù¤­¤Ç¤Ï¤Ê¤¤¡£)

Îã:

# /etc/passwd ¥Õ¥¡¥¤¥ë¤Î¥ì¥Ý¡¼¥È
format STDOUT_TOP =
                        Passwd File
Name                Login    Office   Uid   Gid Home
------------------------------------------------------------------
.
format STDOUT =
@<<<<<<<<<<<<<<<<<< @||||||| @<<<<<<@>>>> @>>>> @<<<<<<<<<<<<<<<<<
$name,              $login,  $office,$uid,$gid, $home
# ¥Ð¥°¥ì¥Ý¡¼¥È·Á¼°
format STDOUT_TOP =
                        Bug Reports
@<<<<<<<<<<<<<<<<<<<<<<<     @|||         @>>>>>>>>>>>>>>>>>>>>>>>
$system,                      $%,         $date
------------------------------------------------------------------
.
format STDOUT =
Subject: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
         $subject
Index: @<<<<<<<<<<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<
       $index,                       $description
Priority: @<<<<<<<<<< Date: @<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<
          $priority,        $date,   $description
From: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<
      $from,                         $description
Assigned to: @<<<<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<
             $programmer,            $description
~                                    ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                                     $description
~                                    ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                                     $description
~                                    ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                                     $description
~                                    ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                                     $description
~                                    ^<<<<<<<<<<<<<<<<<<<<<<<...
                                     $description
.

Ʊ¤¸½ÐÎÏ¥Á¥ã¥ó¥Í¥ë¤ËÂФ·¤Æ write ¤ò»È¤Ã¤Æ ½ÐÎϤòº®ºß¤µ¤»¤ë¤³¤È¤Ï²Äǽ¤Ç¤¢¤ë¤¬¡¢ $- (¥Ú¡¼¥¸¤Ë»Ä¤Ã¤Æ¤¤¤ë¹Ô)¤ò¼«Ê¬¤Ç°·¤ï¤Í¤Ð¤Ê¤é¤Ê¤¤¡£ See section @hbox{@hbox to 1.6em{@tt@$-@hfil} : ½ÐÎÏ¥Á¥ã¥ó¥Í¥ë¤Î¥Ú¡¼¥¸¤Ë»Ä¤Ã¤Æ¤¤¤ë¹Ô¿ô}.

¤Û¤È¤ó¤É¤¬¶õÇò¤Ç¤¢¤ë¤è¤¦¤Ê¥Õ¥£¡¼¥ë¥É¤ò½ÐÎϤ¹¤ë¾ì¹ç¤Ï¡¢ ¥ì¥³¡¼¥É¤Î´Ö¤Ç reset ±é»»»Ò¤ò»È¤¦¤³¤È¤ò¹Í¤¨¤¿Êý¤¬¤è¤¤¡£ ¤è¤ê¸úΨŪ¤Ç¤¢¤ë¤À¤±¤Ç¤Ê¤¯¡¢ ¥Õ¥£¡¼¥ë¥É¤òÁý¤ä¤·¤Æ¡¢½é´ü²½¤¹¤ë¤Î¤ò˺¤ì¤Æ¤·¤Þ¤¦¤È¤¤¤¦¥Ð¥°¤òËɤ²¤ë¡£ See section reset.

¥×¥í¥»¥¹´ÖÄÌ¿®

perl ¤Î¥×¥í¥»¥¹´ÖÄÌ¿®¤ÎǽÎϤϥС¼¥¯¥ì¥¤¤Î¥½¥±¥Ã¥Èµ¡¹½¤Ë´ð¤Å¤¤¤Æ¤¤¤ë¡£ ¥½¥±¥Ã¥È¤¬¤Ê¤¤¤Î¤Ê¤é¡¢¤³¤Î¹à¤ÏÆɤޤʤ¯¤Æ¤è¤¤¡£

´Ø¿ô¤ÏÂбþ¤¹¤ë¥·¥¹¥Æ¥à¥³¡¼¥ë¤ÈƱ¤¸Ì¾Á°¤¬¤Ä¤¤¤Æ¤¤¤ë¤¬¡¢ °ú¿ô¤ÏÆó¤Ä¤ÎÍýͳ¤Ç°ã¤¦¾ì¹ç¤¬¤¢¤ë¡£ ¤Þ¤º¡¢perl ¤Î¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤Ï C ¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤È¤ÏƯ¤­¤¬°ã¤¦¡£ ¼¡¤Ë¡¢perl ¤Ïʸ»úÎóŤòÃΤäƤ¤¤ë¤Î¤Ç¡¢¤½¤Î¾ðÊó¤ÏÅϤµ¤Ê¤¯¤Æ¤è¤¤¡£

°Ê²¼¤Ë¥¯¥é¥¤¥¢¥ó¥È¤Î¥µ¥ó¥×¥ë¤ò¼¨¤¹(¥Æ¥¹¥È¤·¤Æ¤¤¤Ê¤¤)¡£

($them,$port) = @ARGV;
$port = 2345 unless $port;
$them = 'localhost' unless $them;

$SIG{'INT'} = 'dokill';
sub dokill { kill 9,$child if $child; }

require 'sys/socket.ph';

$sockaddr = 'S n a4 x8';
chop($hostname = `hostname`);

($name, $aliases, $proto) = getprotobyname('tcp');
($name, $aliases, $port) = getservbyname($port, 'tcp')
     unless $port =~ /^\d+$/;
($name, $aliases, $type, $len, $thisaddr) =
     gethostbyname($hostname);
($name, $aliases, $type, $len, $thataddr) = gethostbyname($them);

$this = pack($sockaddr, &AF_INET, 0, $thisaddr);
$that = pack($sockaddr, &AF_INET, $port, $thataddr);

socket(S, &PF_INET, &SOCK_STREAM, $proto) || die "socket: $!";
bind(S, $this) || die "bind: $!";
connect(S, $that) || die "connect: $!";

select(S); $| = 1; select(stdout);

if ($child = fork) {
     while (<>) {
        print S;
     }
     sleep 3;
     do dokill();
}
else {
     while (<S>) {
        print;
     }
}

¤½¤·¤Æ¤³¤ì¤¬¥µ¡¼¥Ð¡¼¤Ç¤¢¤ë¡£

($port) = @ARGV;
$port = 2345 unless $port;

require 'sys/socket.ph';

$sockaddr = 'S n a4 x8';

($name, $aliases, $proto) = getprotobyname('tcp');
($name, $aliases, $port) = getservbyname($port, 'tcp')
     unless $port =~ /^\d+$/;

$this = pack($sockaddr, &AF_INET, $port, "\0\0\0\0");

select(NS); $| = 1; select(stdout);

socket(S, &PF_INET, &SOCK_STREAM, $proto) || die "socket: $!";
bind(S, $this) || die "bind: $!";
listen(S, 5) || die "connect: $!";

select(S); $| = 1; select(stdout);

for (;;) {
     print "Listening again\n";
     ($addr = accept(NS,S)) || die $!;
     print "accept ok\n";

     ($af,$port,$inetaddr) = unpack($sockaddr,$addr);
     @inetaddr = unpack('C4',$inetaddr);
     print "$af $port @inetaddr\n";

     while (<NS>) {
        print;
        print NS;
     }
}

ͽÌóÊÑ¿ô

°Ê²¼¤Î̾Á°¤ÎÊÑ¿ô¤Ï perl ¤Ë¤ª¤¤¤ÆÆÃÊ̤ʰÕÌ£¤ò¤â¤Ä¡£ ¤³¤Î¤¦¤Á´ö¤Ä¤«¤Ï¥¢¥ë¥Õ¥¡¥Ù¥Ã¥È¤Î̾Á°¤ò»ý¤¿¤»¤Æ¤âÎɤ«¤Ã¤¿¤Î¤À¤¬¡¢ Á´ÊÑ¿ô¤ò `a-zA-Z' ¤Ç¥ê¥»¥Ã¥È¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¤è¤¦¤Ë¤¹¤ë¤¿¤á¡¢ ¤½¤¦¤Ï¤·¤Ê¤«¤Ã¤¿¡£ ¤³¤Î¤¿¤á¡¢¤ï¤±¤Îʬ¤«¤é¤Ê¤¤¥·¥ó¥Ü¥ë̾¤Ç¶ìÏ«¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£

¤Û¤È¤ó¤É¤Î¤â¤Î¤Ï¤½¤ì¤Ê¤ê¤Ë³Ð¤¨°×¤¤¤â¤Î¤Þ¤¿¤Ï¥·¥§¥ëÊÑ¿ô¤È»÷¤¿¤â¤Î¤Ë¤·¤Æ¤¢¤ë¡£

@hbox{@hbox to 1.6em{@tt@$@_@hfil} : ÆþÎϤª¤è¤Ó¥Ñ¥¿¡¼¥ó¸¡º÷¤Ë¤ª¤±¤ë¥Ç¥Õ¥©¥ë¥È}

$_ : ÆþÎϤª¤è¤Ó¥Ñ¥¿¡¼¥ó¸¡º÷¤Ë¤ª¤±¤ë¥Ç¥Õ¥©¥ë¥È¡£

¼¡¤Î¼°¤Î¥Ú¥¢¤Ï¤½¤ì¤¾¤ìÅù²Á¤Ç¤¢¤ë¡£

while (<>) { ...     # only equivalent in while!
while ($_ = <>) { ...

/^Subject:/
$_ =~ /^Subject:/

y/a-z/A-Z/
$_ =~ y/a-z/A-Z/

chop
chop($_)

³Ð¤¨Êý:
(underline is understood in certain operations.)

@hbox{@hbox to 1.6em{@tt@$.@hfil} : ºÇ¸å¤ËÆɤ߹þ¤ß¤ò¹Ô¤Ã¤¿¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤Î¸½ºß¤Î¹ÔÈÖ¹æ}

$. : ºÇ¸å¤ËÆɤ߹þ¤ß¤ò¹Ô¤Ã¤¿¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤Î¸½ºß¤Î¹ÔÈֹ档

»²¾È¤Î¤ß²Äǽ¡£¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤òÌÀ¼¨Åª¤Ë¥¯¥í¡¼¥º¤·¤¿»þ¤Î¤ß¥ê¥»¥Ã¥È¤µ¤ì¤ë¡£

<> ¤ÏÌÀ¼¨Åª¤Ê¥¯¥í¡¼¥º¤ò¹Ô¤ï¤Ê¤¤¤Î¤Ç¡¢ ARGV ¥Õ¥¡¥¤¥ë¤òÆɤó¤Ç¤¤¤¯¤È¡¢¹ÔÈÖ¹æ¤Ï¤É¤ó¤É¤óÁý²Ã¤¹¤ë¡£ ( eof ¤ÎÎã¤ò»²¾È¡£)See section eof.

³Ð¤¨Êý:
¿¤¯¤Î¥×¥í¥°¥é¥à¤Ë¤ª¤¤¤Æ `.' ¤Ï¸½ºß¤Î¹ÔÈÖ¹æ¤ò¼¨¤¹¤¿¤á¤ËÍѤ¤¤é¤ì¤ë¡£

@hbox{@hbox to 1.6em{@tt@$/@hfil} : ÆþÎϥ쥳¡¼¥É¤Î¥»¥Ñ¥ì¡¼¥¿}

$/ : ÆþÎϥ쥳¡¼¥É¤Î¥»¥Ñ¥ì¡¼¥¿¡£¥Ç¥Õ¥©¥ë¥È¤Ï newline ¡£

awk ¤ÎÊÑ¿ô RS ¤Î¤è¤¦¤ÊƯ¤­¤ò¤¹¤ë¡£ ¥Ì¥ëʸ»úÎó¤ò¥»¥Ã¥È¤¹¤ë¤È¡¢¥Ö¥é¥ó¥¯¹Ô¤ò¶èÀÚ¤ê¤È¤¹¤ëÅÀ¤âƱ¤¸¤Ç¤¢¤ë¡£ Ê£¿ôʸ»ú¤«¤é¤Ê¤ëʸ»úÎó¤ò¥»¥Ã¥È¤·¤Æ¡¢ Ê£¿ôʸ»ú¤Î¥Ç¥ê¥ß¥Ã¥¿¤Ë¥Þ¥Ã¥Á¤µ¤»¤ë¤³¤È¤â²Äǽ¤Ç¤¢¤ë¡£

Ãí°Õ: ¥Õ¥¡¥¤¥ë¤¬Ï¢Â³¤·¤Æ¶õ¹Ô¤ò´Þ¤à¾ì¹ç¡¢ $/ ¤ò "\n\n" ¤Ë¥»¥Ã¥È¤¹¤ë¤Î¤È¡¢ "" ¤Ë¥»¥Ã¥È¤¹¤ë¤Î¤È¤Ç¤Ï¾¯¤·°ÕÌ£¤¬°Û¤Ê¤ë¡£ "" ¤Ë¥»¥Ã¥È¤¹¤ë¤È¡¢2 ¹Ô°Ê¾å¤ÎϢ³¤¹¤ë¶õ¹Ô¤ò 1 ¹Ô¤Î¶õ¹Ô¤È¤·¤Æ°·¤¦¡£ "\n\n" ¤Ë¥»¥Ã¥È¤¹¤ë¤È¡¢ ¼¡¤Îʸ»ú¤Ï(¤½¤ì¤¬²þ¹Ôʸ»ú¤Ç¤¢¤Ã¤Æ¤â)¼¡¤Î¥Ñ¥é¥°¥é¥Õ¤Î°ìÉô¤Ç¤¢¤ë¤Èñ½ã¤Ë¸«¤Ê¤¹¡£

³Ð¤¨Êý:
`/' ¤Ï»í¤ò°úÍѤ¹¤ë»þ¡¢¹Ô¤Î¶­³¦¤òʬ¤±¤ë¤Î¤Ë»È¤ï¤ì¤ë¡£

@hbox{@hbox to 1.6em{@tt@$,@hfil} : ¥³¥ó¥Þ¤Ç¶èÀڤä¿ print ´Ø¿ô¤Î°ú¿ô¤Î½ÐÎÏ¥»¥Ñ¥ì¡¼¥¿}

$, : ¥³¥ó¥Þ¤Ç¶èÀڤä¿ print ´Ø¿ô¤Î°ú¿ô¤Î½ÐÎÏ¥»¥Ñ¥ì¡¼¥¿

Ä̾ print ¤Ï¥³¥ó¥Þ¤Ç¶èÀÚ¤é¤ì¤¿¥Õ¥£¡¼¥ë¥É¤ò¤½¤Î¤Þ¤Þ(²¿¤â¤Ä¤±¤º¤Ë)½ÐÎϤ¹¤ë¡£ awk ¤Î¤è¤¦¤Ë½ÐÎϤ¹¤ë¤Ë¤Ï¡¢awk ÊÑ¿ô OFS ¤Ë¥»¥Ã¥È¤¹¤ëÃÍ (¥Õ¥£¡¼¥ë¥É´Ö¤ò²¿¤Ç¶èÀڤ뤫)¤ò¤³¤ÎÊÑ¿ô¤Ë¥»¥Ã¥È¤¹¤ë¡£

³Ð¤¨Êý:
print ´Ø¿ô¤Ë¤ª¤¤¤Æ `,' ¤Ç¶èÀÚ¤ë¤È½ÐÎϤµ¤ì¤ëʸ»ú¡£

@hbox{@hbox to 1.6em{@tt@$"@hfil} : ÇÛÎóÃͤò " " ¤Ç°Ï¤ó¤À»þ¤ËÍ×ÁÇ´Ö¤ËÆþ¤ë¥»¥Ñ¥ì¡¼¥¿}

$" : ÇÛÎóÃͤò "" ¤Ç°Ï¤ó¤À»þ¤ËÍ×ÁÇ´Ö¤ËÆþ¤ë¥»¥Ñ¥ì¡¼¥¿

ÇÛÎóÃͤ¬ " ¤Ç°Ï¤Þ¤ì¤¿Ê¸»úÎó¤ËÊÑ´¹¤µ¤ì¤ë»þ (¤Þ¤¿¤ÏƱÍͤËÊÑ´¹¤µ¤ì¤ëʸ»úÎó)¤ËŬÍѤµ¤ì¤ëÅÀ¤ò½ü¤¤¤Æ¡¢ $, ¤ÈƱ¤¸¡£¥Ç¥Õ¥©¥ë¥È¤Ï¥¹¥Ú¡¼¥¹¡£

³Ð¤¨Êý:
ÌÀ¤é¤«¤À¤È»×¤¦¤Î¤À¤¬¡£

@hbox{@hbox to 1.6em{@tt@$@char'134@hfil} : print ´Ø¿ô¤ÎºÇ¸å¤Ë½ÐÎϤ¹¤ë¥»¥Ñ¥ì¡¼¥¿}

$\ : print ´Ø¿ô¤ÎºÇ¸å¤Ë½ÐÎϤ¹¤ë¥»¥Ñ¥ì¡¼¥¿

Ä̾print ¤Ï¥³¥ó¥Þ¤Ç¶èÀÚ¤é¤ì¤¿¥Õ¥£¡¼¥ë¥É¤ò½ÐÎϤ¹¤ë»þ¡¢ ºÇ¸å¤Ë newline ¤ä¥ì¥³¡¼¥É¥»¥Ñ¥ì¡¼¥¿¤ò¤Ä¤±¤º¤Ë½ÐÎϤ¹¤ë¡£ awk ¤Î¤è¤¦¤Ë½ÐÎϤ¹¤ë¤Ë¤Ï¡¢awk ¤Î ORS ÊÑ¿ô¤Ë¥»¥Ã¥È¤¹¤ëÃÍ (print ¤ÎºÇ¸å¤Ë²¿¤ò½ÐÎϤ¹¤ë¤«)¤ò¤³¤ÎÊÑ¿ô¤Ë¥»¥Ã¥È¤¹¤ë¡£

³Ð¤¨Êý:
print ¤ÎºÇ¸å¤Ë \n ¤ò¤Ä¤±¤ëÂؤï¤ê¤Ë $\ ¤ò¥»¥Ã¥È¤¹¤ë¡£ ¤Þ¤¿¡¢`\' ¤Ï `/' ¤È»÷¤Æ¤¤¤ë¤¬¡¢ ¤½¤ì¤Ï"µÕ¤Ë" perl ¤«¤é¥Ç¡¼¥¿¤ò¼õ¤±¼è¤ë»þ¤Ë»È¤¦¡£

@hbox{@hbox to 1.6em{@tt@$#@hfil} : ¿ô»ú¤Î½ÐÎÏ¥Õ¥©¡¼¥Þ¥Ã¥È}

$# : ¿ô»ú¤Î½ÐÎÏ¥Õ¥©¡¼¥Þ¥Ã¥È

¤³¤ÎÊÑ¿ô¤Ï¡¢ awk ¤Î OFMT ÊÑ¿ô¤òÉÔ´°Á´¤Ë¥¨¥ß¥å¥ì¡¼¥È¤·¤è¤¦¤È¤·¤¿¤â¤Î¤Ç¤¢¤ë¡£ ¤À¤¬¡¢awk ¤È perl ¤Ç"²¿¤¬¿ôÃͤ«"¤òȽÃǤ¹¤ëºÝ¤Ë°ã¤¤¤¬½Ð¤ë¤³¤È¤¬¤¢¤ë¡£ ¤Þ¤¿¡¢½é´üÃÍ¤Ï %.6g ¤Ç¤Ï¤Ê¤¯ %.20g ¤Ç¤¢¤ë¤Î¤Ç¡¢ awk ¤ÈƱ¤¸½ÐÎϤòÆÀ¤ë¤Ë¤Ï¡¢$# ¤ò¥»¥Ã¥È¤¹¤ëɬÍפ¬¤¢¤ë¡£

³Ð¤¨Êý:
`#' ¤Ï¿ô¤òɽ¤¹¡£

@hbox{@hbox to 1.6em{@tt@$@%@hfil} : ¥Á¥ã¥ó¥Í¥ë¤Î¸½ºß¤Î¥Ú¡¼¥¸ÈÖ¹æ}

$% : ¸½ºß¥»¥ì¥¯¥È¤µ¤ì¤Æ¤¤¤ë½ÐÎÏ¥Á¥ã¥ó¥Í¥ë¤Î¸½ºß¤Î¥Ú¡¼¥¸Èֹ档

³Ð¤¨Êý:
nroff ¤Ë¤ª¤¤¤Æ `%' ¤Ï¥Ú¡¼¥¸ÈÖ¹æ¤Ç¤¢¤ë¡£

@hbox{@hbox to 1.6em{@tt@$=@hfil} : ½ÐÎÏ¥Á¥ã¥ó¥Í¥ë¤Î¸½ºß¤Î¥Ú¡¼¥¸Ä¹¤µ}

$= : ¸½ºß¥»¥ì¥¯¥È¤µ¤ì¤Æ¤¤¤ë½ÐÎÏ¥Á¥ã¥ó¥Í¥ë¤Î¸½ºß¤Î¥Ú¡¼¥¸Ä¹¤µ (½ÐÎϲÄǽ¹Ô¿ô)¡£

¥Ç¥Õ¥©¥ë¥È¤Ï 60¡£

³Ð¤¨Êý:
`=' ¤Ï¿åÊ¿¤ÊÀþ¤«¤é¤Ç¤­¤Æ¤¤¤ë¡£

@hbox{@hbox to 1.6em{@tt@$-@hfil} : ½ÐÎÏ¥Á¥ã¥ó¥Í¥ë¤Î¥Ú¡¼¥¸¤Ë»Ä¤Ã¤Æ¤¤¤ë¹Ô¿ô}

$- : ¸½ºß¥»¥ì¥¯¥È¤µ¤ì¤Æ¤¤¤ë½ÐÎÏ¥Á¥ã¥ó¥Í¥ë¤Î¥Ú¡¼¥¸¤Ë»Ä¤Ã¤Æ¤¤¤ë¹Ô¿ô¡£

³Ð¤¨Êý:
¥Ú¡¼¥¸¤Î¹Ô¿ô - ½ÐÎϤ·¤¿¹Ô¿ô¡£

@hbox{@hbox to 1.6em{@tt@$~@hfil} : ½ÐÎÏ¥Á¥ã¥ó¥Í¥ë¤Î¸½ºß¤Î¥ì¥Ý¡¼¥È¥Õ¥©¡¼¥Þ¥Ã¥È̾}

$~ : ¸½ºß¥»¥ì¥¯¥È¤µ¤ì¤Æ¤¤¤ë½ÐÎÏ¥Á¥ã¥ó¥Í¥ë¤Î ¸½ºß¤Î¥ì¥Ý¡¼¥È¥Õ¥©¡¼¥Þ¥Ã¥È¤Î̾Á°¡£ ¥Ç¥Õ¥©¥ë¥È¤Ï¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë̾¡£

³Ð¤¨Êý:
$^ ¤Î·»Äï¡£

@hbox{@hbox to 1.6em{@tt@$^@hfil} : ½ÐÎÏ¥Á¥ã¥ó¥Í¥ë¤Î¸½ºß¤Î¥Ú¡¼¥¸¥È¥Ã¥×̾}

$^ : ¸½ºß¥»¥ì¥¯¥È¤µ¤ì¤Æ¤¤¤ë½ÐÎÏ¥Á¥ã¥ó¥Í¥ë¤Î¸½ºß¤Î¥Ú¡¼¥¸¥È¥Ã¥×¤Î̾Á°¡£ ¥Ç¥Õ¥©¥ë¥È¤Ï¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë̾¤Ë `_TOP' ¤ò¤Ä¤±¤¿¤â¤Î¡£

³Ð¤¨Êý:
¥Ú¡¼¥¸¤Î¥È¥Ã¥×¤ò»Ø¤·¤Æ¤¤¤ë¡£

@hbox{@hbox to 1.6em{@tt@$|@hfil} : write ¤Þ¤¿¤Ï print ¤Î¸å¤Ë¥Õ¥é¥Ã¥·¥å¤ò¹Ô¤¦¤«Èݤ«}

$| : write ¤Þ¤¿¤Ï print ¤Î¸å¤Ë¥Õ¥é¥Ã¥·¥å¤ò¹Ô¤¦¤«Èݤ«

Èó 0 ¤Ë¥»¥Ã¥È¤¹¤ë¤È¡¢¸½ºß¥»¥ì¥¯¥È¤µ¤ì¤Æ¤¤¤ë½ÐÎÏ¥Á¥ã¥ó¥Í¥ë¤ËÂФ¹¤ë Á´¤Æ¤Î write ¤Þ¤¿¤Ï print ¤Î¸å¤Ë¥Õ¥é¥Ã¥·¥å¤ò¹Ô¤¦¡£ ¥Ç¥Õ¥©¥ë¥È¤Ï 0 ¤Ç¤¢¤ë¡£

STDOUT ¤ÏüËö¤Ø¤Î½ÐÎϤϹԥХåե¡¥ê¥ó¥°¤µ¤ì¡¢ ¤½¤ì°Ê³°¤Ï¥Ö¥í¥Ã¥¯¥Ð¥Ã¥Õ¥¡¥ê¥ó¥°¤µ¤ì¤ë¤³¤È¤ËÃí°Õ¡£ ¤³¤ÎÊÑ¿ô¤ò¥»¥Ã¥È¤¹¤ë¤È¡¢perl ¥¹¥¯¥ê¥×¥È¤ò rsh ¤Î²¼¤ÇÁö¤é¤»¤Æ¡¢ ²¿¤¬µ¯¤³¤Ã¤Æ¤¤¤ë¤«¤ò¤½¤Î»þ¤Ë¸«¤¿¤¤¾ì¹ç¤Ê¤É¡¢¥Ñ¥¤¥×¤Ë½ÐÎϤ¹¤ëºÝ¤ËÊØÍø¤Ç¤¢¤ë¡£

³Ð¤¨Êý:(?)
(when you want your pipes to be piping hot.)

@hbox{@hbox to 1.6em{@tt@$@$@hfil} : ¥¹¥¯¥ê¥×¥È¤òÁö¤é¤»¤Æ¤¤¤ë perl ¤Î¥×¥í¥»¥¹ÈÖ¹æ}

$$ : ¥¹¥¯¥ê¥×¥È¤òÁö¤é¤»¤Æ¤¤¤ë perl ¤Î¥×¥í¥»¥¹Èֹ档

³Ð¤¨Êý:
¥·¥§¥ë¤ÈƱ¤¸¡£

@hbox{@hbox to 1.6em{@tt@$?@hfil} : ¥Ñ¥¤¥×¤Î¥¯¥í¡¼¥º¡¢system ´Ø¿ô¤Ê¤É¤ÇÊ֤ä¿¥¹¥Æ¡¼¥¿¥¹}

$? : ºÇ¸å¤Î¥Ñ¥¤¥×¤Î¥¯¥í¡¼¥º¡¢`¥³¥Þ¥ó¥É`¡¢ system ´Ø¿ô¤«¤éÊ֤ä¿¥¹¥Æ¡¼¥¿¥¹¡£

¤³¤ì¤Ï¥·¥¹¥Æ¥à¥³¡¼¥ë wait() ¤«¤éÊ֤ä¿¥¹¥Æ¡¼¥¿¥¹¥ï¡¼¥É¤Ç¤¢¤ê¡¢ ¥µ¥Ö¥×¥í¥»¥¹¤Î¼ÂºÝ¤Î½ªÎ»ÃÍ¤Ï $? >> 8 ¤Ç¤¢¤ë¤³¤È¤ËÃí°Õ¡£

$? & 255 ¤Ë¤è¤ê¡¢¥×¥í¥»¥¹¤¬½ªÎ»¤¹¤ë¸¶°ø¤È¤Ê¤Ã¤¿¥·¥°¥Ê¥ë(¤â¤·¤¢¤ì¤Ð)¡¢ ¤ª¤è¤Ó¥³¥¢¥À¥ó¥×¤¬¤¢¤Ã¤¿¤«¤É¤¦¤«¤¬ÆÀ¤é¤ì¤ë¡£

³Ð¤¨Êý:
`sh' ¤ª¤è¤Ó `ksh' ¤ÈƱ¤¸¡£

@hbox{@hbox to 1.6em{@tt@$@&@hfil} : ºÇ¸å¤ËÀ®¸ù¤·¤¿¥Ñ¥¿¡¼¥ó¥Þ¥Ã¥Á¤Ç¥Þ¥Ã¥Á¤·¤¿Ê¸»úÎó}

$& : ºÇ¸å¤ËÀ®¸ù¤·¤¿¥Ñ¥¿¡¼¥ó¥Þ¥Ã¥Á¤Ç¥Þ¥Ã¥Á¤·¤¿Ê¸»úÎó¡£

¥Ö¥í¥Ã¥¯¤ä¸½ºß¤Î¥Ö¥í¥Ã¥¯¤Ç°Ï¤Þ¤ì¤Æ¤¤¤ë eval ¤ÎÃæ¤Î¥Þ¥Ã¥Á¤Ï Á´¤¯¥«¥¦¥ó¥È¤·¤Æ¤¤¤Ê¤¤¡£

³Ð¤¨Êý:
¤¤¤¯¤Ä¤«¤Î¥¨¥Ç¥£¥¿¤Ë¤ª¤±¤ë `&' ¤ÈƱ¤¸¡£

@hbox{@hbox to 1.6em{@tt@$`@hfil} : ºÇ¸å¤ËÀ®¸ù¤·¤¿¥Ñ¥¿¡¼¥ó¥Þ¥Ã¥Á¤Ç¥Þ¥Ã¥Á¤·¤¿Ê¸»úÎó¤ÎÁ°¤Îʸ»úÎó}

$` : ºÇ¸å¤ËÀ®¸ù¤·¤¿¥Ñ¥¿¡¼¥ó¥Þ¥Ã¥Á¤Ç¥Þ¥Ã¥Á¤·¤¿Ê¸»úÎó¤ÎÁ°¤Îʸ»úÎó¡£

¥Ö¥í¥Ã¥¯¤ä¸½ºß¤Î¥Ö¥í¥Ã¥¯¤Ç°Ï¤Þ¤ì¤Æ¤¤¤ë eval ¤ÎÃæ¤Î¥Þ¥Ã¥Á¤Ï Á´¤¯¥«¥¦¥ó¥È¤·¤Æ¤¤¤Ê¤¤¡£

³Ð¤¨Êý:
``' ¤Ï°úÍÑʸ»úÎó¤ÎÁ°¤ËÍè¤ë¤³¤È¤¬Â¿¤¤¡£

@hbox{@hbox to 1.6em{@tt@$'@hfil} : ºÇ¸å¤ËÀ®¸ù¤·¤¿¥Ñ¥¿¡¼¥ó¥Þ¥Ã¥Á¤Ç¥Þ¥Ã¥Á¤·¤¿Ê¸»úÎó¤Î¸å¤Ë³¤¯Ê¸»úÎó}

$' : ºÇ¸å¤ËÀ®¸ù¤·¤¿¥Ñ¥¿¡¼¥ó¥Þ¥Ã¥Á¤Ç¥Þ¥Ã¥Á¤·¤¿Ê¸»úÎó¤Î¸å¤Ë³¤¯Ê¸»úÎó¡£

¥Ö¥í¥Ã¥¯¤ä¸½ºß¤Î¥Ö¥í¥Ã¥¯¤Ç°Ï¤Þ¤ì¤Æ¤¤¤ë eval ¤ÎÃæ¤Î¥Þ¥Ã¥Á¤Ï Á´¤¯¥«¥¦¥ó¥È¤·¤Æ¤¤¤Ê¤¤¡£

³Ð¤¨Êý:
`'' ¤Ï°úÍÑʸ»úÎó¤Î¸å¤ËÍè¤ë¤³¤È¤¬Â¿¤¤¡£

(Îã)

$_ = 'abcdefghi';
/def/;
print "$`:$&:$'\n";      # prints abc:def:ghi

@hbox{@hbox to 1.6em{@tt@$+@hfil} : ºÇ¸å¤Î¸¡º÷¥Ñ¥¿¡¼¥ó¤Ç¥Þ¥Ã¥Á¤·¤¿ºÇ¸å¤Î³ç¸Ì}

$+ : ºÇ¸å¤Î¸¡º÷¥Ñ¥¿¡¼¥ó¤Ë¤ª¤¤¤Æ¥Þ¥Ã¥Á¤·¤¿ºÇ¸å¤Î³ç¸Ì¡£

Ê£¿ô¸õÊä¤Î¥Ñ¥¿¡¼¥ó¸¡º÷¤Ç¡¢ ¤É¤Á¤é¤¬¥Þ¥Ã¥Á¤·¤¿¤«¤¬¤ï¤«¤é¤Ê¤¤¤È¤­¤ËÊØÍø¤Ç¤¢¤ë¡£

(Îã)

/Version: (.*)|Revision: (.*)/ && ($rev = $+);

³Ð¤¨Êý: ?
be positive and forward looking.

@hbox{@hbox to 1.6em{@tt@$*@hfil} : Ê£¿ô¹Ô¥Ñ¥¿¡¼¥ó¥Þ¥Ã¥Á¥ó¥°¤ò¹Ô¤¦¤«Èݤ«}

$* : Ê£¿ô¹Ô¥Ñ¥¿¡¼¥ó¥Þ¥Ã¥Á¥ó¥°¤ò¹Ô¤¦¤«Èݤ«

¥Ñ¥¿¡¼¥ó¥Þ¥Ã¥Á¤òºÇŬ²½¤¹¤ë¤¿¤á¤Ë¡¢ ʸ»úÎóÆâ¤ÇÊ£¿ô¹Ô¥Þ¥Ã¥Á¥ó¥°¤ò¹Ô¤¦»þ 1 ¤Ë¥»¥Ã¥È¤·¡¢ ʸ»úÎó¤¬ 1 ¹Ô¤·¤«´Þ¤Þ¤Ê¤¤¤³¤È¤ò perl ¤ËÃΤ餻¤ë¤¿¤á¤Ë 0 ¤ò¥»¥Ã¥È¤¹¤ë¡£

$* ¤ò 0 ¤Ë¤·¤Æ¤¤¤ë¤È¡¢ newline ¤òÊ£¿ô´Þ¤àʸ»úÎó¤ËÂФ¹¤ë¥Ñ¥¿¡¼¥ó¥Þ¥Ã¥Á¤Ïº®Í𤷤¿·ë²Ì¤òÊÖ¤¹¤³¤È¤¬¤¢¤ë¡£ ¥Ç¥Õ¥©¥ë¥È¤Ï 0 ¤Ç¤¢¤ë¡£

³Ð¤¨Êý:
`*' ¤ÏÊ£¿ô¤Ë¥Þ¥Ã¥Á¤¹¤ë¡£

Ãí°Õ: ¤³¤ÎÊÑ¿ô¤Ï ^ ¤ä $ ¤Î²ò¼á¤Ë¤Î¤ß±Æ¶Á¤òÍ¿¤¨¤ë¡£ ²þ¹Ôʸ»ú¤Ï $* == 0 ¤Ç¤¢¤Ã¤Æ¤â¸¡º÷¤Ç¤­¤ë¡£

@hbox{@hbox to 1.6em{@tt@$0@hfil} : ¼Â¹Ô¤·¤Æ¤¤¤ë perl ¥¹¥¯¥ê¥×¥È¤Î¥Õ¥¡¥¤¥ë̾}

$0 : ¼Â¹Ô¤·¤Æ¤¤¤ë perl ¥¹¥¯¥ê¥×¥È¤Î¥Õ¥¡¥¤¥ë̾¡£ $0 ¤ËÂåÆþ¤ò¹Ô¤¦¤È¡¢ps(1) ¥×¥í¥°¥é¥à¤¬»²¾È¤¹¤ë°ú¿ôÎΰè¤òÊѹ¹¤¹¤ë¡£

³Ð¤¨Êý:
sh ¤ä ksh ¤ÈƱ¤¸¡£

{@tt@$¿ô»ú} : ¥Ñ¥¿¡¼¥ó¥Þ¥Ã¥Á¥ó¥°¤Î³ç¸Ì¤Î¿ô¤ËÂбþ¤·¤¿¥µ¥Ö¥Ñ¥¿¡¼¥ó

$¿ô»ú : ºÇ¸å¤Ë¹Ô¤Ã¤¿¥Ñ¥¿¡¼¥ó¥Þ¥Ã¥Á¤Î³ç¸Ì¤Î¿ô¤ËÂбþ¤·¤¿¥µ¥Ö¥Ñ¥¿¡¼¥ó¡£

´û¤Ë¼Â¹Ô¤ò½ª¤¨¤¿¥Í¥¹¥È¥Ö¥í¥Ã¥¯Æâ¤Î¥Ñ¥¿¡¼¥ó¤Ï¥«¥¦¥ó¥È¤µ¤ì¤Ê¤¤¡£

³Ð¤¨Êý:
\¿ô»ú ¤Ë»÷¤Æ¤¤¤ë¡£

@hbox{@hbox to 1.6em{@tt@$[@hfil} : ÇÛÎó¤ÎºÇ½é¤ÎÍ×ÁǤ䡢¥µ¥Ö¥¹¥È¥ê¥ó¥°¤ÎºÇ½é¤Îʸ»ú¤Îź¤¨»ú}

$[ : ÇÛÎó¤ÎºÇ½é¤ÎÍ×ÁǤ䥵¥Ö¥¹¥È¥ê¥ó¥°¤ÎºÇ½é¤Îʸ»ú¤Îź¤¨»ú¡£

¥Ç¥Õ¥©¥ë¥È¤Ï0 ¤À¤¬¡¢perl ¤ò awk (¤Þ¤¿¤Ï Fortran)¤Î¤è¤¦¤ËÆ°¤«¤·¤¿¤±¤ì¤Ð¡¢ ź¤¨»ú¤ò»È¤¦»þ¡¢ index() ¤ä substr() ¤ò¼Â¹Ô¤¹¤ë»þ¤Ë 1 ¤Ë¥»¥Ã¥È¤¹¤ì¤Ð¤è¤¤¡£

³Ð¤¨Êý:
`[' ¤Ïź¤¨»ú¤Î»Ï¤Þ¤ê¡£

@hbox{@hbox to 1.6em{@tt@$]@hfil} : ¥Ð¡¼¥¸¥ç¥ó¤òɽ¤¹Ê¸»úÎó}

$] : `perl -v' ¤òÆþÎϤ·¤¿»þ¤Ë½ÐÎϤµ¤ì¤ëʸ»úÎó¡£

¥¹¥¯¥ê¥×¥È¤ò¼Â¹Ô¤·¤Æ¤¤¤ë perl ¥¤¥ó¥¿¥×¥ê¥¿¤¬ Àµ¤·¤¤¥Ð¡¼¥¸¥ç¥ó¤Ç¤¢¤ë¤«¤É¤¦¤«¤ò¥¹¥¯¥ê¥×¥È¤ÎºÇ½é¤ÇÄ´¤Ù¤ë¤Î¤Ë»È¤¨¤ë¡£ ¿ôÃͤΥ³¥ó¥Æ¥­¥¹¥È¤ÇÍѤ¤¤ë¤È¡¢`version + patchlevel / 1000' ¤òÊÖ¤¹¡£

(Îã)

# getc ¤¬»È¤¨¤ë¤«¤É¤¦¤«Ä´¤Ù¤ë
   ($version,$patchlevel) =
      $] =~ /(\d+\.\d+).*\nPatch level: (\d+)/;
   print STDERR "(No filename completion available.)\n"
      if $version * 1000 + $patchlevel < 2016;

¤Þ¤¿¤Ï¡¢¿ôÃͤȤ·¤ÆÍѤ¤¤ë¤È¡¢

warn "No checksumming!\n" if $] < 3.019;

³Ð¤¨Êý: ?
(Is this version of perl in the right bracket?)

@hbox{@hbox to 1.6em{@tt@$;@hfil} : ¿¼¡¸µÇÛÎ󥨥ߥå¥ì¡¼¥·¥ç¥ó¤ÎºÝ¤Îź¤¨»ú¤Î¶èÀÚ¤ê}

$; : ¿¼¡¸µÇÛÎó¤Î¥¨¥ß¥å¥ì¡¼¥·¥ç¥ó¤ÎºÝ¤Îź¤¨»ú¤Î¶èÀڤꡣ

Ï¢ÁÛÇÛÎó¤ÎÍ×ÁǤò

$foo{$a,$b,$c}

¤Î¤è¤¦¤Ë»²¾È¤¹¤ì¤Ð¡¢¤½¤ì¤Ï¼ÂºÝ¤Ï

$foo{join($;, $a, $b, $c)}

¤ò°ÕÌ£¤¹¤ë¡£

¤·¤«¤·¡¢

@foo{$a,$b,$c}      # a slice--note the @

¤ÏÂÌÌܤǤ¢¤ë¡£¤Ê¤¼¤Ê¤é¡¢¤³¤ì¤Ï

($foo{$a},$foo{$b},$foo{$c})

¤ò°ÕÌ£¤¹¤ë¤«¤é¤Ç¤¢¤ë¡£

¥Ç¥Õ¥©¥ë¥È¤Ï \034 ¤Ç¡¢awk ¤Î SUBSEP ¤ÈƱ¤¸¤Ç¤¢¤ë¡£

Ï¢ÁÛÇÛÎó¤Î¥­¡¼¤Ë¥Ð¥¤¥Ê¥ê¡¼¥Ç¡¼¥¿¤¬´Þ¤Þ¤ì¤ë¾ì¹ç¤Ï¡¢ $; ¤È¤·¤Æ°ÂÁ´¤ÊÃͤϤʤ¤¡£

³Ð¤¨Êý:
¥³¥ó¥Þ(ʸˡŪ¤Êź¤¨»ú¶èÀÚ¤ê)¤Ï¥»¥ß-¥»¥ß¥³¥í¥ó¤Ç¤¢¤ë¡£ ¤¤¤ä¡¢¤Á¤ç¤Ã¤È¶ñ¹ç¤¬°­¤¤¤Î¤Ï¤ï¤«¤Ã¤Æ¤ë¤ó¤À¤±¤É¡¢ $, ¤Ï¤â¤¦¤Û¤«¤Î¤â¤Ã¤È½ÅÍפʤâ¤Î¤Ë»È¤Ã¤Æ¤·¤Þ¤Ã¤¿¤«¤é¤Í¡£

@hbox{@hbox to 1.6em{@tt@$!@hfil} : errno ¤Î¸½ºßÃͤޤ¿¤Ï¥·¥¹¥Æ¥à¥¨¥é¡¼Ê¸»úÎó}

$! : errno ¤Î¸½ºßÃͤޤ¿¤Ï¥·¥¹¥Æ¥à¥¨¥é¡¼Ê¸»úÎó

¿ôÃͤΥ³¥ó¥Æ¥­¥¹¥È¤Ç»È¤¦¤È¡¢ Ä̾ï½Ð¤µ¤ì¤ë·Ù¹ð¤È¶¦¤Ë errno ¤Î¸½ºß¤ÎÃͤòÊÖ¤¹¡£ (¤Ä¤Þ¤ê¡¢¥·¥¹¥Æ¥à¥¨¥é¡¼¤ò¼¨¤¹ÆÃÄê¤Î¥¨¥é¡¼¤¬Ê֤俤ΤǤʤ¤¤«¤®¤ê¡¢ $! ¤ÎÃͤϰÕÌ£¤¬¤Ê¤¤¤³¤È¤Ë¤Ê¤ë¡£)

ʸ»úÎó¤Î¥³¥ó¥Æ¥­¥¹¥È¤Ç»È¤¦¤È¡¢¥·¥¹¥Æ¥à¥¨¥é¡¼Ê¸»úÎó¤òÊÖ¤¹¡£

errno ¤ò¥»¥Ã¥È¤¹¤ë¤¿¤á¤Ë $! ¤ËÂåÆþ¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£

Î㤨¤Ð¡¢$! ¤Ë¥¨¥é¡¼ n ¤ËÂбþ¤¹¤ëʸ»úÎó¤òÆþ¤ì¤ÆÊÖ¤¹¾ì¹ç¡¢ ¤Þ¤¿¤Ï die ´Ø¿ô¤Î½ªÎ»Ãͤò¥»¥Ã¥È¤·¤¿¤¤¾ì¹ç¡¢¤Ê¤É¡£

³Ð¤¨Êý:
What just went bang?

@hbox{@hbox to 1.6em{@tt@$@@hfil} : ºÇ¸å¤Ë¹Ô¤Ã¤¿ eval ¤Î¥·¥ó¥¿¥Ã¥¯¥¹¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸}

$@ : ºÇ¸å¤Ë¹Ô¤Ã¤¿ eval ¥³¥Þ¥ó¥É¤Î¥·¥ó¥¿¥Ã¥¯¥¹¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¡£

¥Ì¥ë¤Ê¤é¤Ð¡¢ºÇ¸å¤Ë¹Ô¤Ã¤¿ eval ¤Ï²òÀÏ¡¦¼Â¹Ô¤¬Àµ¤·¤¯¹Ô¤ï¤ì¤¿¤³¤È¤ò¼¨¤¹¡£ (µ¯Æ°¤·¤¿½èÍý¤ÏÉáÄÌ¤Ë [in a normal fashion] ¼ºÇÔ¤·¤¿¤«¤â¤·¤ì¤Ê¤¤¤¬)

³Ð¤¨Êý:
Where was the syntax error "at"?

@hbox{@hbox to 1.6em{@tt@$<@hfil} : ¥×¥í¥»¥¹¤Î¼Â uid}

$< : ¥×¥í¥»¥¹¤Î¼Â uid¡£

³Ð¤¨Êý:
setuid ¥¹¥¯¥ê¥×¥È¤òÁö¤é¤»¤Æ¤¤¤ë¾ì¹ç¡¢·¯¤Ï¤É¤³¤«¤éÍ褿¤Î¤«?

@hbox{@hbox to 1.6em{@tt@$>@hfil} : ¥×¥í¥»¥¹¤Î¼Â¸ú uid}

$> : ¥×¥í¥»¥¹¤Î¼Â¸ú uid¡£

(Îã)

$< = $>;  # ¼Â uid ¤ò¼Â¸ú uid ¤Ë¥»¥Ã¥È¤¹¤ë
($<,$>) = ($>,$<);  # ¼Â uid ¤È¼Â¸ú uid ¤òÆþ¤ìÂؤ¨¤ë

³Ð¤¨Êý:
setuid ¥¹¥¯¥ê¥×¥È¤òÁö¤é¤»¤Æ¤¤¤ë¾ì¹ç¡¢·¯¤Ï¤É¤³¤Ø¹Ô¤Ã¤¿¤Î¤«?

(Ãí°Õ)
$< ¤ä $> ¤Ï¡¢ setreuid() ¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤ë¥Þ¥·¥ó¤Ç¤Î¤ß swap ¤Ç¤­¤ë¡£

@hbox{@hbox to 1.6em{@tt@$(@hfil} : ¥×¥í¥»¥¹¤Î¼Â gid}

$( : ¥×¥í¥»¥¹¤Î¼Â gid¡£

Ʊ»þ¤ËÊ£¿ô¤Î¥°¥ë¡¼¥×¤Ë°¤¹¤ë¤³¤È¤ò¥µ¥Ý¡¼¥È¤¹¤ë¥Þ¥·¥ó¤Ç¤Ï¡¢ ¥¹¥Ú¡¼¥¹¤Ç¶èÀÚ¤é¤ì¤¿¥æ¡¼¥¶¤¬Â°¤·¤Æ¤¤¤ë¥°¥ë¡¼¥×¤Î¥ê¥¹¥È¤È¤Ê¤ë¡£ ºÇ½é¤Î¤â¤Î¤Ï getgid() ¤ÇÆÀ¤é¤ì¤ë¤â¤Î¤Ç¤¢¤ë¡£ »Ä¤ê¤Ï getgroups() ¤ÇÆÀ¤é¤ì¤ë¤â¤Î¤Ç¤¢¤ê¡¢ ¤½¤ÎÆâ¤Î°ì¤Ä¤ÏºÇ½é¤Î¤â¤Î¤ÈƱ¤¸¤«¤âÃΤì¤Ê¤¤¡£

³Ð¤¨Êý:
³ç¸Ì¤Ï¡¢¤â¤Î¤ò¥°¥ë¡¼¥×²½¤¹¤ë¤Î¤Ë»È¤¦¡£ setgid ¥×¥í¥°¥é¥à¤òÁö¤é¤»¤Æ¤¤¤ë¾ì¹ç¡¢ ¼Â gid ¤È¤Ï¡¢¤¢¤Ê¤¿¤¬»Ä¤·¤Æ(left = º¸)Í褿¥°¥ë¡¼¥×¤Ç¤¢¤ë¡£

@hbox{@hbox to 1.6em{@tt@$)@hfil} : ¥×¥í¥»¥¹¤Î¼Â¸ú gid}

$) : ¥×¥í¥»¥¹¤Î¼Â¸ú gid¡£

Ʊ»þ¤ËÊ£¿ô¤Î¥°¥ë¡¼¥×¤Ë°¤¹¤ë¤³¤È¤ò¥µ¥Ý¡¼¥È¤¹¤ë¥Þ¥·¥ó¤Ç¤Ï¡¢ ¥¹¥Ú¡¼¥¹¤Ç¶èÀÚ¤é¤ì¤¿¥æ¡¼¥¶¤¬Â°¤·¤Æ¤¤¤ë¥°¥ë¡¼¥×¤Î¥ê¥¹¥È¤È¤Ê¤ë¡£ ºÇ½é¤Î¤â¤Î¤Ï getegid() ¤ÇÆÀ¤é¤ì¤ë¤â¤Î¤Ç¤¢¤ë¡£ »Ä¤ê¤Ï getgroups() ¤ÇÆÀ¤é¤ì¤ë¤â¤Î¤Ç¤¢¤ê¡¢ ¤½¤ÎÆâ¤Î°ì¤Ä¤ÏºÇ½é¤Î¤â¤Î¤ÈƱ¤¸¤«¤âÃΤì¤Ê¤¤¡£

³Ð¤¨Êý:
³ç¸Ì¤Ï¡¢¤â¤Î¤ò¥°¥ë¡¼¥×²½¤¹¤ë¤Î¤Ë»È¤¦¡£ setgid ¥×¥í¥°¥é¥à¤òÁö¤é¤»¤Æ¤¤¤ë¾ì¹ç¡¢ ¼Â¸ú gid ¤È¤Ï¡¢¤¢¤Ê¤¿¤Ë¤È¤Ã¤ÆÀµÅö¤Ê(right = ±¦)¥°¥ë¡¼¥×¤Ç¤¢¤ë¡£

(Ãí°Õ)
$<¡¢$>¡¢$(¡¢$)¤Ï Âбþ¤¹¤ë set[re][ug]id() ¥ë¡¼¥Á¥ó¤ò¥µ¥Ý¡¼¥È¤¹¤ë¥Þ¥·¥ó¤Ç¤Î¤ß¥»¥Ã¥È¤µ¤ì¤ë¡£ $( ¤È $) ¤Ï¡¢ setregid() ¤ò¥µ¥Ý¡¼¥È¤¹¤ë¥Þ¥·¥ó¤Ç¤Î¤ß swap ¤Ç¤­¤ë¡£

@hbox{@hbox to 1.6em{@tt@$:@hfil} : format ¤Çʸ»úÎó¤òʬ¤±¤ëºÝ¤ÎľÁ°¤Îʸ»úÎ󥻥åÈ}

$: : format ¤Çʸ»úÎó¤òʬ¤±¤ëºÝ¤ÎľÁ°¤Îʸ»úÎ󥻥åÈ

format ¤Ë¤ª¤¤¤Æ¡¢Ê¸»úÎó¤¬Ê¬¤±¤é¤ì¤Æ·Ñ³¥Õ¥£¡¼¥ë¥É (^ ¤Ç»Ï¤Þ¤ë)¤ËÆþ¤ë»þ¤Î¤½¤ÎľÁ°¤Îʸ»ú¥»¥Ã¥È¡£ ¥Ç¥Õ¥©¥ë¥È¤Ï ` \n-' ¤Ç¡¢ ʸ»úÎó¤Ï¥Û¥ï¥¤¥È¥¹¥Ú¡¼¥¹Ëô¤Ï¥Ï¥¤¥Õ¥ó¤Î¸å¤Çʬ¤±¤é¤ì¤ë¡£

³Ð¤¨Êý:
a "colon" in poetry is a part of a line.

@hbox{@hbox to 1.6em{@tt@$^D@hfil} : ¥Ç¥Ð¥Ã¥°¥Õ¥é¥°¤ÎÃÍ}

$^D : ¸½ºß¤Î¥Ç¥Ð¥Ã¥°¥Õ¥é¥°¤ÎÃÍ¡£

³Ð¤¨Êý:
-D ¥¹¥¤¥Ã¥Á¤ÎÃÍ¡£

@hbox{@hbox to 1.6em{@tt@$^F@hfil} : ¥·¥¹¥Æ¥à¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ÎºÇÂçÃÍ}

$^F : ¥·¥¹¥Æ¥à¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ÎºÇÂçÃͤǡ¢Ä̾ï 2¡£

¥·¥¹¥Æ¥à¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ï»Ò¥×¥í¥»¥¹¤ËÅϤµ¤ì¤ë¤¬¡¢ ¤½¤ì¤è¤êÃͤ¬Â礭¤¤¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ÏÅϤµ¤ì¤Ê¤¤¡£ open ¤ÎºÝ¤Ë¤Ï¡¢ ¤¿¤È¤¨ open ¤¬¼ºÇÔ¤·¤Æ¤â¥·¥¹¥Æ¥à¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ÏÊݸ¤µ¤ì¤ë¡£ Ä̾ï¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ï open ¤ò»î¤ß¤ëÁ°¤Ë close ¤µ¤ì¤ë¡£

³Ð¤¨Êý:
-D ¥¹¥¤¥Ã¥Á¤ÎÃÍ¡£

@hbox{@hbox to 1.6em{@tt@$^I@hfil} : ¥Õ¥¡¥¤¥ë¤ò¤½¤Î¾ì¤ÇÊѹ¹¤¹¤ë¾ì¹ç¤Î³ÈÄ¥»Ò¤ÎÃÍ}

$^I : ¥Õ¥¡¥¤¥ë¤ò¤½¤Î¾ì¤ÇÊѹ¹¤¹¤ë¾ì¹ç¤Î³ÈÄ¥»Ò¤ÎÃÍ¡£

¤½¤Î¾ì¤ÇÊѹ¹¤¹¤ë¤Î¤ò¶Ø»ß¤¹¤ë¤Ë¤Ï¡¢¤³¤ì¤ò undef ¤¹¤ë¡£

³Ð¤¨Êý:
-i ¥¹¥¤¥Ã¥Á¤ÎÃÍ¡£

@hbox{@hbox to 1.6em{@tt@$^L@hfil} : ²þ¥Ú¡¼¥¸¥³¡¼¥É}

$^L : ²þ¥Ú¡¼¥¸¥³¡¼¥É¡£¥Ç¥Õ¥©¥ë¥È¤Ï \f¡£

@hbox{@hbox to 1.6em{@tt@$^P@hfil} : ¥Ç¥Ð¥Ã¥¬ÍÑÆâÉô¥Õ¥é¥°}

$^P : ¥Ç¥Ð¥Ã¥¬¤¬¼«Ê¬¼«¿È¤ò¥Ç¥Ð¥Ã¥°¤·¤Ê¤¤¤¿¤á¤Ë¥¯¥ê¥¢¤¹¤ëÆâÉô¥Õ¥é¥°¡£

¤³¤ì¤ò¥¯¥ê¥¢¤¹¤ë¤³¤È¤Ç ¼«Ê¬¼«¿È¤ò¥Ç¥Ð¥Ã¥°¤¹¤ë¤³¤È¤òÉÔ²Äǽ¤Ë¤¹¤ë¤³¤È¤¬¹Í¤¨¤é¤ì¤ë¡£

@hbox{@hbox to 1.6em{@tt@$^T@hfil} : ¥¹¥¯¥ê¥×¥È¤Î¼Â¹Ô¤¬»Ï¤Þ¤Ã¤¿»þ¹ï}

$^T : ¥¹¥¯¥ê¥×¥È¤Î¼Â¹Ô¤¬»Ï¤Þ¤Ã¤¿»þ¹ï(epoch ¤«¤é¤ÎÉÿô)¡£

¥Õ¥¡¥¤¥ë¥Æ¥¹¥È -M,-A,-C ¤ÇÊÖ¤ëÃͤϤ³¤ÎÃͤ˴ð¤Å¤¤¤Æ¤¤¤ë¡£

@hbox{@hbox to 1.6em{@tt@$^W@hfil} : ·Ù¹ð¥¹¥¤¥Ã¥Á¤ÎÃÍ}

$^W : ¸½ºß¤Î·Ù¹ð¥¹¥¤¥Ã¥Á¤ÎÃÍ¡£

³Ð¤¨Êý:
-w ¥¹¥¤¥Ã¥Á¤Ë´ØÏ¢¤·¤¿ÃÍ¡£

@hbox{@hbox to 1.6em{@tt@$^X@hfil} : Perl ¤¬µ¯Æ°¤µ¤ì¤¿ºÝ¤Î̾Á°}

$^X : Perl ¤½¤Î¤â¤Î¤¬µ¯Æ°¤µ¤ì¤¿ºÝ¤Î̾Á°¡£argv[0] ¤«¤éÆÀ¤ë¡£

{@tt@$ARGV} : <> ¤«¤éÆɤ߹þ¤ó¤Ç¤¤¤ë¤È¤­¤Î¥«¥ì¥ó¥È¥Õ¥¡¥¤¥ë̾

$ARGV : <> ¤«¤éÆɤ߹þ¤ó¤Ç¤¤¤ë»þ¡¢¥«¥ì¥ó¥È¥Õ¥¡¥¤¥ë̾¤¬Æþ¤Ã¤Æ¤¤¤ë¡£

{@tt@ARGV} : ¥¹¥¯¥ê¥×¥È¤ËÍ¿¤¨¤é¤ì¤¿¥³¥Þ¥ó¥É¥é¥¤¥ó°ú¿ô

@ARGV : ¥¹¥¯¥ê¥×¥È¤ËÍ¿¤¨¤é¤ì¤¿¥³¥Þ¥ó¥É¥é¥¤¥ó°ú¿ô¡£

$#ARGV ¤ÏÄÌ¾ï °ú¿ô¤Î¿ô - 1 ¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤³¤È¤ËÃí°Õ¡£ ¤Ê¤¼¤Ê¤é¡¢$ARGV[0] ¤ÏºÇ½é¤Î°ú¿ô¤Ç¤¢¤Ã¤Æ¡¢ ¥³¥Þ¥ó¥É¤Î̾Á°¤Ç¤Ï¤Ê¤¤¤«¤é¤À¡£ ¥³¥Þ¥ó¥É̾¤òÃΤë¤Ë¤Ï $0 ¤ò¸«¤è¡£

See section @hbox{@hbox to 1.6em{@tt@$0@hfil} : ¼Â¹Ô¤·¤Æ¤¤¤ë perl ¥¹¥¯¥ê¥×¥È¤Î¥Õ¥¡¥¤¥ë̾}.

{@tt@INC} : perl ¥¹¥¯¥ê¥×¥È¤òõ¤¹¾ì½ê¤Î¥ê¥¹¥È

@INC: perl ¥¹¥¯¥ê¥×¥È¤òõ¤¹¾ì½ê¤Î¥ê¥¹¥È

do EXPR ¥³¥Þ¥ó¥É¤Þ¤¿¤Ï require ¥³¥Þ¥ó¥É¤Çɾ²Á¤µ¤ì¤ë¡£

ºÇ½é¤Ï ¥³¥Þ¥ó¥É¥¹¥¤¥Ã¥Á -I ¤Ç»ØÄꤷ¤¿°ú¿ô + ¥Ç¥Õ¥©¥ë¥È perl ¥é¥¤¥Ö¥é¥ê
(¿ʬ `/usr/local/lib/perl'¡¢ ¼¡¤Ë `.' ¤¹¤Ê¤ï¤Á¥«¥ì¥ó¥È¥Ç¥£¥ì¥¯¥È¥ê )¤¬Æþ¤Ã¤Æ¤¤¤ë¡£

{@tt %INC} : ¥¤¥ó¥¯¥ë¡¼¥É¤·¤¿¥Õ¥¡¥¤¥ë¤Î°ÌÃÖ

%INC : ¥¤¥ó¥¯¥ë¡¼¥É¤·¤¿¥Õ¥¡¥¤¥ë¤Î°ÌÃÖ

Ï¢ÁÛÇÛÎó INC ¤Ë¤Ï do ¤Þ¤¿¤Ï require ¤òÍѤ¤¤Æ ¥¤¥ó¥¯¥ë¡¼¥É¤µ¤ì¤¿¥Õ¥¡¥¤¥ë̾¤¬Æþ¤Ã¤Æ¤¤¤ë¡£ key ¤Ï»ØÄꤷ¤¿¥Õ¥¡¥¤¥ë̾¡¢ value ¤Ï¥Õ¥¡¥¤¥ë¤¬¼ÂºÝ¤Ë¸«¤Ä¤«¤Ã¤¿¾ì½ê¤Ç¤¢¤ë¡£

`require' ¥³¥Þ¥ó¥É¤Ï¤³¤ÎÇÛÎó¤òÍѤ¤¤Æ »ØÄꤷ¤¿¥Õ¥¡¥¤¥ë¤¬´û¤Ë¥¤¥ó¥¯¥ë¡¼¥É¤µ¤ì¤¿¤«¤É¤¦¤«¤ò·èÄꤹ¤ë¡£

{@tt %ENV} : ´Ä¶­ÊÑ¿ô

%ENV : ¸½ºß¤Î´Ä¶­¡£

ENV ¤ÎÃͤòÊѹ¹¤¹¤ë¤È¡¢»Ò¥×¥í¥»¥¹¤Î´Ä¶­¤âÊѤï¤ë¡£

{@tt %SIG} : signal ¥Ï¥ó¥É¥é¤Î¥ê¥¹¥È

%SIG : ¤µ¤Þ¤¶¤Þ¤Ê signal ¤ËÂбþ¤¹¤ë¥Ï¥ó¥É¥é¤ò¥»¥Ã¥È¤¹¤ë¡£

(Îã)

sub handler {  # 1st argument is signal name
     local($sig) = @_;
     print "Caught a SIG$sig--shutting down\n";
     close(LOG);
     exit(0);
}

$SIG{'INT'} = 'handler';
$SIG{'QUIT'} = 'handler';
...
$SIG{'INT'} = 'DEFAULT'; # ¥Ç¥Õ¥©¥ë¥È¤Î¥¢¥¯¥·¥ç¥ó¤ËÌ᤹
$SIG{'QUIT'} = 'IGNORE'; # SIGQUIT ¤ò̵»ë¤¹¤ë

ÇÛÎó SIG ¤Ï perl ¥¹¥¯¥ê¥×¥È¤Ç¥»¥Ã¥È¤µ¤ì¤¿ signal ¤ËÂбþ¤¹¤ëÃͤ·¤« ´Þ¤Þ¤Ê¤¤¡£

¥Ñ¥Ã¥±¡¼¥¸

perl ¤Ë¤ª¤¤¤Æ¤Ï¥Ñ¥Ã¥±¡¼¥¸´Ö¤ÇÊÑ¿ô¤¬´³¾Ä¤·¤¢¤ï¤Ê¤¤¤è¤¦¤Ë¤¹¤ë¤¿¤á¡¢ ÊÌ¡¹¤Î̾Á°¶õ´Ö¤òÍÑ°Õ¤·¤Æ¤¤¤ë¡£¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¡¢ perl ¥¹¥¯¥ê¥×¥È¤Ï main ¤È¤¤¤¦¥Ñ¥Ã¥±¡¼¥¸¤Ë¥³¥ó¥Ñ¥¤¥ë¤µ¤ì¤ë¡£

package Àë¸À¤ò»È¤¦¤È¡¢Ì¾Á°¶õ´Ö¤òÊѤ¨¤ë¤³¤È¤¬¤Ç¤­¤ë¡£ ¥Ñ¥Ã¥±¡¼¥¸Àë¸À¤Î¸ú¤¯ÈϰϤϡ¢Àë¸À¤«¤éÊĤ¸¤¿¥Ö¥í¥Ã¥¯¤ÎºÇ¸å¤Þ¤Ç¤Ç¤¢¤ë (local() Àë¸À»Ò¤ÈƱ¤¸)¡£ Ä̾¥Ñ¥Ã¥±¡¼¥¸Àë¸À¤Ï require ¤Ç¥¤¥ó¥¯¥ë¡¼¥É¤µ¤ì¤ë¥Õ¥¡¥¤¥ë¤Î ºÇ½é¤ÎÀë¸À¤È¤·¤Æ»È¤¦¡£

°ì²Õ½ê°Ê¾å¤Ç¥Ñ¥Ã¥±¡¼¥¸¤ò»È¤¦¤³¤È¤¬¤Ç¤­¤ë¡£ ¤½¤ì¤Ïñ¤Ë¥Ö¥í¥Ã¥¯¤Î»Ä¤ê¤ËÂФ·¤Æ¥³¥ó¥Ñ¥¤¥é¤¬»È¤¦ ¥·¥ó¥Ü¥ë¥Æ¡¼¥Ö¥ë¤¬ÊѤï¤ë¤À¤±¤Ç¤¢¤ë¡£

¼±Ê̻Ҥ˥ѥ屡¼¥¸Ì¾¤È '(¥·¥ó¥°¥ë¥¯¥©¡¼¥È)¤ò¤Ä¤±¤ë¤³¤È¤Ç¡¢ ¾¤Î¥Ñ¥Ã¥±¡¼¥¸¤ÎÊÑ¿ô¤ä¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤ò»²¾È¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£ ¥Ñ¥Ã¥±¡¼¥¸Ì¾¤¬¤Ê¤±¤ì¤Ð¡¢main ¤¬»È¤ï¤ì¤ë¡£

¥¢¥ë¥Õ¥¡¥Ù¥Ã¥È¤Ç»Ï¤Þ¤ë¼±Ê̻ҤΤߥѥ屡¼¥¸¤Î¥·¥ó¥Ü¥ë¥Æ¡¼¥Ö¥ë¤Ë³ÊǼ¤µ¤ì¤ë¡£ ¾¤Î¥·¥ó¥Ü¥ë¤Ï main ¥Ñ¥Ã¥±¡¼¥¸¤Ë³ÊǼ¤µ¤ì¤ë¡£ ¤µ¤é¤Ë¡¢¼±ÊÌ»Ò STDIN¡¢STDOUT¡¢STDERR¡¢ARGV¡¢ ARGVOUT¡¢ENV¡¢INC¡¢SIG ¤Ï ¤½¤ìËÜÍè¤ÎÌÜŪ°Ê³°¤Ë»È¤¦¾ì¹ç¤Ç¤â¥Ñ¥Ã¥±¡¼¥¸ main ¤Î¤Þ¤Þ¤Ç¤¢¤ë¡£

¤Þ¤¿¡¢`m'¡¢`s'¡¢`y' ¤È¤¤¤¦Ì¾Á°¤Î¥Ñ¥Ã¥±¡¼¥¸¤ò»È¤¦¤È¡¢ ¥Ñ¥Ã¥±¡¼¥¸Ì¾¤ò¤Ä¤±¤¿¼±Ê̻Ҥò»È¤¦¤³¤È¤Ï¤Ç¤­¤Ê¤¤¡£ ¤Ê¤¼¤Ê¤é¡¢¤½¤ì¤¾¤ì¥Ñ¥¿¡¼¥ó¥Þ¥Ã¥Á¡¢ÃÖ´¹¡¢ÊÑ´¹ ¤òɽ¤¹¤È²ò¼á¤µ¤ì¤ë¤«¤é¤Ç¤¢¤ë¡£

eval ¤µ¤ì¤ëʸ»úÎó¤Ï eval ¤ÈƱ¤¸¥Ñ¥Ã¥±¡¼¥¸¤Ë¥³¥ó¥Ñ¥¤¥ë¤µ¤ì¤ë¡£ (¤¿¤À¤·¡¢$SIG{} ¤Ø¤ÎÂåÆþ¤Ë¤ª¤¤¤Æ¤Ï¡¢ ¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤Ï main ¥Ñ¥Ã¥±¡¼¥¸¤Ë¤¢¤ë¤È²¾Äꤵ¤ì¤ë¡£ ¥Ñ¥Ã¥±¡¼¥¸Æâ¤Ë¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤òºî¤ê¤¿¤¤¾ì¹ç¤Ï ¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é̾¤Ë¥Ñ¥Ã¥±¡¼¥¸Ì¾¤ò¤Ä¤±¤ë¤³¤È¡£)

Îã¤È¤·¤Æ¤Ï¡¢perl ¥é¥¤¥Ö¥é¥ê¤Ë¤¢¤ë `perldb.pl' ¤¬¤¢¤ë¡£ ¤³¤ì¤Ï¡¢¥Ç¥Ð¥Ã¥¬¤¬¥Ç¥Ð¥Ã¥°¤·¤è¤¦¤È¤¹¤ë¥¹¥¯¥ê¥×¥ÈÆâ¤ÎÊÑ¿ô¤ò´³¾Ä¤·¤Ê¤¤¤è¤¦¤Ë¡¢ ºÇ½é¤Ë DB ¥Ñ¥Ã¥±¡¼¥¸¤ËÆþ¤ë¡£ ¤½¤·¤Æ¡¢¤¤¤í¤¤¤í¤Ê¾ì¹ç¤Ë¡¢ main ¥Ñ¥Ã¥±¡¼¥¸¤Îʸ̮¤Ç expression ¤òɾ²Á¤¹¤ë¤¿¤á¤Ë °ì»þŪ¤Ë main ¥Ñ¥Ã¥±¡¼¥¸¤ËÀÚ¤êÊѤï¤ë¡£

¥Ñ¥Ã¥±¡¼¥¸¤Î¥·¥ó¥Ü¥ë¥Æ¡¼¥Ö¥ë¤Ï ¥Ñ¥Ã¥±¡¼¥¸Ì¾¤ÎÁ°¤Ë `_' ¤ò¤Ä¤±¤¿Ì¾Á°¤ÎÏ¢ÁÛÇÛÎó¤Ë³ÊǼ¤µ¤ì¤Æ¤¤¤ë¡£ Ï¢ÁÛÇÛÎó¤Î³Æ¥¨¥ó¥È¥ê¤ÎÃͤϡ¢ *name µ­Ë¡¤ò»È¤¦ºÝ¤Ë»²¾È¤µ¤ì¤ëÃͤÈƱ¤¸¤Ç¤¢¤ë¡£ ¼ÂºÝ¡¢¼¡¤ÎÎã¤ÏƱ¤¸¸ú²Ì¤¬¤¢¤ë(¤â¤Á¤í¤ó main ¥Ñ¥Ã¥±¡¼¥¸¤Ë¤ª¤¤¤Æ)¤¬¡¢ °ì¤ÄÌܤÎÊý¤¬¡¢¥³¥ó¥Ñ¥¤¥ë»þ¤Ë¥·¥ó¥Ü¥ë¥Æ¡¼¥Ö¥ë¤òõ¤¹¤Î¤Ç¡¢¤è¤ê¸úΨ¤¬¤è¤¤¡£

local(*foo) = *bar;
local($_main{'foo'}) = $_main{'bar'};

¤³¤ì¤ò»È¤Ã¤ÆÎ㤨¤Ð¥Ñ¥Ã¥±¡¼¥¸Æâ¤ÎÁ´ÊÑ¿ô¤ò½ÐÎϤ¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£ °Ê²¼¤Ë perl ¥é¥¤¥Ö¥é¥ê¤«¤é `dumpvar.pl' ¤ò¼¨¤¹¡£

package dumpvar;

sub main'dumpvar {
    ($package) = @_;
    local(*stab) = eval("*_$package");
    while (($key,$val) = each(%stab)) {
        {
            local(*entry) = $val;
            if (defined $entry) {
                print "\$$key = '$entry'\n";
            }
            if (defined @entry) {
                print "\@$key = (\n";
                foreach $num ($[ .. $#entry) {
                    print "  $num\t'",$entry[$num],"'\n";
                }
                print ")\n";
            }
            if ($key ne "_$package" && defined %entry) {
                print "\%$key = (\n";
                foreach $key (sort keys(%entry)) {
                    print "  $key\t'",$entry{$key},"'\n";
                }
                print ")\n";
            }
        }
    }
}

¤³¤Î¥µ¥Ö¥ë¡¼¥Á¥ó¤Ï dumpvar ¥Ñ¥Ã¥±¡¼¥¸Æâ¤Ë¥³¥ó¥Ñ¥¤¥ë¤µ¤ì¤ë¤¬¡¢ main ¥Ñ¥Ã¥±¡¼¥¸¤Ë¤ª¤¤¤Æ¥µ¥Ö¥ë¡¼¥Á¥ó̾¤ò»ÈÍѲÄǽ¤È¤¹¤ë¤¿¤á¤Ë¡¢ ¥µ¥Ö¥ë¡¼¥Á¥ó̾¤ÎÁ°¤Ë¥Ñ¥Ã¥±¡¼¥¸Ì¾¤ò¤Ä¤±¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¤³¤È¤ËÃí°Õ¡£

¥×¥í¥°¥é¥ß¥ó¥°¥¹¥¿¥¤¥ë

¥×¥í¥°¥é¥Þ¤Ë¤Ï³§¡¢ÅöÁ³¤Ê¤¬¤é¡¢Âκۤ˴ؤ·¤Æ¼«Ê¬¼«¿È¤Î¹¥¤ß¤¬¤¢¤ë¤¬¡¢ ¥×¥í¥°¥é¥à¤òÆɤ߰פ¯¤¹¤ë¤¿¤á¤Î°ìÈÌŪ¤Ê¥¬¥¤¥É¥é¥¤¥ó¤¬¤¤¤¯¤Ä¤«¤¢¤ë¡£

  1. ¤¢¤ë¤³¤È¤ò¤¢¤ëÊýË¡¤Ç¤Ç¤­¤ë¤«¤é¤È¤¤¤Ã¤Æ¡¢ ¤½¤ì¤Ï¤½¤ÎÊýË¡¤Ç¤»¤Í¤Ð¤Ê¤é¤Ê¤¤¤È¤¤¤¦¤³¤È¤Ç¤Ï¤Ê¤¤¡£ perl ¤Ï¤É¤ó¤Ê¤³¤È¤ò¤¹¤ë¾ì¹ç¤Ç¤âÊ£¿ô¤ÎÊýË¡¤¬¤¢¤ë¤è¤¦¤ËÀ߷פµ¤ì¤Æ¤¤¤ë¤Î¤Ç¡¢ ¤â¤Ã¤È¤âÆɤ߰פ¤ÊýË¡¤òÁª¤Ö¤Î¤¬¤è¤¤¡£¤¿¤È¤¨¤Ð¡¢
    open(FOO,$foo) || die "Can't open $foo: $!";
    
    ¤Ï¼¡¤è¤ê¤â¤è¤¤¡£
    die "Can't open $foo: $!" unless open(FOO,$foo);
    
    ¤Ê¤¼¤Ê¤é¡¢¸å¼Ô¤Ïʸ¤Î¥á¥¤¥ó¥Ý¥¤¥ó¥È¤ò½¤¾þ»Ò¤È¤·¤Æ±£¤·¤Æ¤¤¤ë¤«¤é¤Ç¤¢¤ë¡£ °ìÊý¡¢
    print "Starting analysis\n" if $verbose;
    
    ¤Ï¼¡¤è¤ê¤â¤è¤¤¡£
    $verbose && print "Starting analysis\n";
    
    ¤Ê¤¼¤Ê¤é¡¢ ¥á¥¤¥ó¥Ý¥¤¥ó¥È¤Ï¥æ¡¼¥¶¤¬ -v ¤ò¥¿¥¤¥×¤·¤¿¤«¤É¤¦¤«¤Ç¤Ï¤Ê¤¤¤«¤é¤À¡£ ƱÍͤˡ¢±é»»»Ò¤¬¥Ç¥Õ¥©¥ë¥È¤Î°ú¿ô¤ò²¾Äꤷ¤Æ¤¤¤ë¤«¤é¤È¤¤¤Ã¤Æ¡¢ ¤½¤ì¤Ï¥Ç¥Õ¥©¥ë¥È¤òÍѤ¤¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¤È¤¤¤¦¤³¤È¤Ç¤Ï¤Ê¤¤¡£ ¥Ç¥Õ¥©¥ë¥È¤Ï¤Á¤ç¤Ã¤È¤·¤¿¥×¥í¥°¥é¥à¤ò½ñ¤¯ ÂÕ¤±¼Ô¤Î¥·¥¹¥Æ¥à¥×¥í¥°¥é¥Þ¤Î¤¿¤á¤Ë¤¢¤ë¡£ ¥×¥í¥°¥é¥à¤òÆɤ߰פ¯¤·¤¿¤±¤ì¤Ð¡¢°ú¿ô¤ò½ñ¤¤¤¿Êý¤¬¤è¤¤¡£ ¾å¤ÈƱ¤¸¤è¤¦¤Ê¤³¤È¤À¤¬¡¢ ¤¢¤Á¤³¤Á¤Ç³ç¸Ì¤ò¾Êά¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¤È¤¤¤¦¤³¤È¤Ï¼¡¤Î¤è¤¦¤Ë½ñ¤±¡¢ ¤È¤¤¤¦¤³¤È¤Ç¤Ï¤Ê¤¤¡£
    return print reverse sort num values array;
    return print(reverse(sort num (values(%array))));
    
    ¤¢¤ä¤Õ¤ä¤Ê»þ¤Ï¡¢³ç¸Ì¤ò¤Ä¤±¤è¤¦¡£ ¾¯¤Ê¤¯¤È¤â¡¢Êª¹¥¤­¤¬¡¢vi ¤Ç % ¥­¡¼¤ò²¡¤¹¤«¤â¤·¤ì¤Ê¤¤¡£(?)

    When in doubt, parenthesize. At the very least it will let some poor schmuck bounce on the % key in vi.

    ¤¢¤ä¤Õ¤ä¤Ç¤Ê¤¤»þ¤Ç¤â¡¢ ·¯¤Î¸å¤ò·Ñ¤¤¤Ç¥³¡¼¥É¤Î¥á¥ó¥Æ¥Ê¥ó¥¹¤ò¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¿Íʪ¤Î Àº¿ÀÊ¡Íø¤ò¹Í¤¨¤è¤¦¡£Èà¤Ï¤ª¤½¤é¤¯¸í¤Ã¤¿½ê¤Ë³ç¸Ì¤ò¤Ä¤±¤ë¤À¤í¤¦¡£
  2. ¥ë¡¼¥×¤ÎºÇ½é¤äºÇ¸å¤Ç¥ë¡¼¥×¤«¤éÈ´¤±¤ë¤è¤¦¤Ê¤æ¤¬¤ó¤À¤³¤È¤ò¤·¤Æ¤Ï¤¤¤±¤Ê¤¤¡£ perl ¤Ï¿¿¤óÃ椫¤éÈ´¤±¤é¤ì¤ë¤è¤¦¤Ë last Àë¸À»Ò¤òÍÑ°Õ¤·¤Æ¤¤¤ë¡£ ¸«°×¤¯¤¹¤ë¤¿¤á¡¢¥¤¥ó¥Ç¥ó¥È¤ò¾¯¤·¾¯¤Ê¤¯¤·¤è¤¦¡£
    line:
     for (;;) {
         statements;
     last line if $foo;
         next line if /^#/;
         statements;
     }
    
  3. °Â¿´¤·¤Æ¥ë¡¼¥×¥é¥Ù¥ë¤ò»È¤¨ -- ¥é¥Ù¥ë¤Ï¿½Å¥ë¡¼¥×¤«¤éÈ´¤±¤ë¤¿¤á¤À¤±¤Ç¤Ê¤¯¡¢ ¤è¤êÆɤ߰פ¯¤¹¤ë¤¿¤á¤Ë¤¢¤ë¡£ °ì¤ÄÁ°¤ÎÎã¤ò¸«¤è¡£
  4. °Ü¿¢À­¤ò¹â¤á¤ë¤Ë¤Ï¡¢Á´¥Þ¥·¥ó¤Ç¥¤¥ó¥×¥ê¥á¥ó¥È¤µ¤ì¤Æ¤¤¤Ê¤¤µ¡Ç½¤ò»È¤¦ºÝ¤Ë¡¢ eval ¹½Â¤¤ÎÃæ¤Ç¤½¤ì¤¬¼ºÇÔ¤¹¤ë¤«¤É¤¦¤«¥Æ¥¹¥È¤»¤è¡£ ¤¢¤ëµ¡Ç½¤¬ ¤É¤Î¥Ð¡¼¥¸¥ç¥ó¡¢¤É¤Î¥Ñ¥Ã¥Á¥ì¥Ù¥ë¤Ç¥¤¥ó¥×¥ê¥á¥ó¥È¤µ¤ì¤¿¤«¤¬Ê¬¤«¤Ã¤Æ¤¤¤ë¤Ê¤é¡¢ $] ¤ò»È¤Ã¤Æ¤½¤Îµ¡Ç½¤¬¤¢¤ë¤«¤É¤¦¤«¤òÄ´¤Ù¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
  5. ³Ð¤¨°×¤¤¼±Ê̻ҤòÁª¤Ù¡£
  6. ¼óÈø°ì´Ó¡£(Be consistent.)

perl ¥Ç¥Ð¥Ã¥¬

perl ¤ò -d ¥ª¥×¥·¥ç¥ó¤ò¤Ä¤±¤Æµ¯Æ°¤¹¤ë¤È¡¢ ¥Ç¥Ð¥Ã¥°¥â¥Ë¥¿¤Î¤â¤È¤Ç¥¹¥¯¥ê¥×¥È¤¬¼Â¹Ô¤µ¤ì¤ë¡£ ¥Ç¥Ð¥Ã¥¬¤ÏºÇ½é¤Î¼Â¹Ô²Äǽʸ¤ÎÁ°¤Ç»ß¤Þ¤ê¡¢°Ê²¼¤Ë¼¨¤¹¥³¥Þ¥ó¥É¤òÆþÎϤ¹¤ë¤è¤¦Â¥¤¹¡£

`h'
¥Ø¥ë¥×¥á¥Ã¥»¡¼¥¸¤ò½ÐÎϤ¹¤ë¡£
`T'
¥¹¥¿¥Ã¥¯¤ò¥È¥ì¡¼¥¹¤¹¤ë¡£
`s'
¥·¥ó¥°¥ë¥¹¥Æ¥Ã¥×¡£¼¡¤Îʸ¤ÎºÇ½é¤Ë㤹¤ë¤Þ¤Ç¼Â¹Ô¤¹¤ë¡£
`n'
Next. ¼¡¤Îʸ¤Î»Ï¤á¤Þ¤Ç¡¢¥µ¥Ö¥ë¡¼¥Á¥ó¤ËÆþ¤é¤º¤Ë¼Â¹Ô¤¹¤ë¡£
`f'
Finish. ¸½ºß¤Î¥µ¥Ö¥ë¡¼¥Á¥ó¤¬½ª¤ï¤ë¤Þ¤Çʸ¤ò¼Â¹Ô¤¹¤ë¡£
`c'
³¹Ô¡£¼¡¤Ë¥Ö¥ì¡¼¥¯¥Ý¥¤¥ó¥È¤Ë㤹¤ë¤Þ¤Ç¼Â¹Ô¤¹¤ë¡£
`c line'
»ØÄꤷ¤¿¹Ô¤Þ¤Ç³¹Ô¤¹¤ë¡£°ì»þŪ¤Ê¥Ö¥ì¡¼¥¯¥Ý¥¤¥ó¥È¤ò»ØÄꤷ¤¿¹Ô¤ËÀßÄꤹ¤ë¡£
`<CR>'
ºÇ¸å¤Î n ¤Þ¤¿¤Ï s ¤ò·«¤êÊÖ¤¹¡£
`l min+incr'
min ¤«¤é incr+1 ¹Ôɽ¼¨¤¹¤ë¡£ min ¤ò¾Êά¤¹¤ë¤È¡¢ºÇ¸å¤Ëɽ¼¨¤·¤¿¼¡¤Î¹Ô¤«¤éɽ¼¨¤¹¤ë¡£ incr ¤ò¾Êά¤¹¤ë¤È¡¢ºÇ¸å¤Î incr ¤ÎÃͤòÍѤ¤¤ë¡£
`l min-max'
»ØÄꤷ¤¿ÈϰϤιԤòɽ¼¨¤¹¤ë¡£
`l line'
»ØÄꤷ¤¿¹Ô¤Î¤ßɽ¼¨¤¹¤ë¡£
`l'
¼¡¤Î¥¦¥£¥ó¥É¥¦¤òɽ¼¨¤¹¤ë¡£
`-'
Á°¤Î¥¦¥£¥ó¥É¥¦¤òɽ¼¨¤¹¤ë¡£
`w line'
¹ÔÉÕ¶á¤Î¥¦¥£¥ó¥É¥¦¤òɽ¼¨¤¹¤ë¡£
`l subname'
¥µ¥Ö¥ë¡¼¥Á¥ó¤òɽ¼¨¤¹¤ë¡£Ä¹¤¤¥µ¥Ö¥ë¡¼¥Á¥ó¤Î¾ì¹ç¤ÏºÇ½é¤À¤±É½¼¨¤¹¤ë¡£ ¹¹¤Ëɽ¼¨¤¹¤ë¤Ë¤Ï l ¤ò»È¤¦¡£
`/pattern/'
Àµµ¬É½¸½¤Î¸åÊýõº÷¡£ºÇ¸å¤Î / ¤Ï¤Ä¤±¤Ê¤¯¤Æ¤â¤è¤¤¡£
`?pattern?'
Àµµ¬É½¸½¤ÎÁ°Êýõº÷¡£ºÇ¸å¤Î ? ¤Ï¤Ä¤±¤Ê¤¯¤Æ¤â¤è¤¤¡£
`L'
¥Ö¥ì¡¼¥¯¥Ý¥¤¥ó¥È¤Þ¤¿¤Ï¥¢¥¯¥·¥ç¥ó¤ò»ý¤Ä¹Ô¤òɽ¼¨¤¹¤ë¡£
`S'
Á´¥µ¥Ö¥ë¡¼¥Á¥ó̾¤òɽ¼¨¤¹¤ë¡£
`t'
¥È¥ì¡¼¥¹¥â¡¼¥É¤ò on/off ¤¹¤ë¥È¥°¥ë¡£
`b line condition'
¥Ö¥ì¡¼¥¯¥Ý¥¤¥ó¥È¤ò¥»¥Ã¥È¤¹¤ë¡£ ¹Ô¤ò¾Êά¤¹¤ë¤È¡¢¼¡¤Ë¼Â¹Ô¤µ¤ì¤ë¸½ºß¹Ô¤Ë¥»¥Ã¥È¤¹¤ë¡£ ¥³¥ó¥Ç¥£¥·¥ç¥ó¤ò»ØÄꤹ¤ë¤È¡¢¤½¤Îʸ¤ËÍè¤ëÅÙ¤Ëɾ²Á¤µ¤ì¡¢ ¥³¥ó¥Ç¥£¥·¥ç¥ó¤¬¿¿¤Î»þ¤Î¤ß¥Ö¥ì¡¼¥¯¥Ý¥¤¥ó¥È¤È¤·¤Æ°·¤ï¤ì¤ë¡£ ¥Ö¥ì¡¼¥¯¥Ý¥¤¥ó¥È¤Ï¼Â¹Ô²Äǽ¤Êʸ¤ÎºÇ½é¤Î¹Ô¤Ë¤Î¤ß¥»¥Ã¥È²Äǽ¤Ç¤¢¤ë¡£
`b subname condition'
¥µ¥Ö¥ë¡¼¥Á¥ó¤ÎºÇ½é¤Î¼Â¹Ô²Äǽ¹Ô¤Ë¥Ö¥ì¡¼¥¯¥Ý¥¤¥ó¥È¤ò¥»¥Ã¥È¤¹¤ë¡£
`d line'
¥Ö¥ì¡¼¥¯¥Ý¥¤¥ó¥È¤òºï½ü¤¹¤ë¡£ ¹Ô¤ò¾Êά¤¹¤ë¤È¡¢¼¡¤Ë¼Â¹Ô¤µ¤ì¤ë¸½ºß¹Ô¤Î¥Ö¥ì¡¼¥¯¥Ý¥¤¥ó¥È¤òºï½ü¤¹¤ë¡£
`D'
Á´¥Ö¥ì¡¼¥¯¥Ý¥¤¥ó¥È¤òºï½ü¤¹¤ë¡£
`a line command'
¹Ô¤Ë¥¢¥¯¥·¥ç¥ó¤ò¥»¥Ã¥È¤¹¤ë¡£ Ê£¿ô¹Ô¤Î¥³¥Þ¥ó¥É¤Ï²þ¹Ô¤ÎÁ°¤Ë¥Ð¥Ã¥¯¥¹¥é¥Ã¥·¥å¤ò¤Ä¤±¤ë¤³¤È¤ÇÆþÎϲÄǽ¤Ç¤¢¤ë¡£
`A'
Á´¤Æ¤Î¹Ô¥¢¥¯¥·¥ç¥ó¤òºï½ü¤¹¤ë¡£
`< command'
¥Ç¥Ð¥Ã¥¬¤¬¥×¥í¥ó¥×¥È¤ò½Ð¤¹Á°¤Ë¼Â¹Ô¤¹¤ë¥¢¥¯¥·¥ç¥ó¤ò¥»¥Ã¥È¤¹¤ë¡£ Ê£¿ô¹Ô¤Î¥³¥Þ¥ó¥É¤Ï²þ¹Ô¤ÎÁ°¤Ë¥Ð¥Ã¥¯¥¹¥é¥Ã¥·¥å¤ò¤Ä¤±¤ë¤³¤È¤ÇÆþÎϲÄǽ¤Ç¤¢¤ë¡£
`> command'
¥×¥í¥ó¥×¥È¤Î¸å¡¢ ¥³¥Þ¥ó¥É¤òÆþÎϤ·¤Æ¥¹¥¯¥ê¥×¥È¼Â¹Ô¤Ë°Ü¤ë»þ¤Ë¼Â¹Ô¤µ¤ì¤ë¥¢¥¯¥·¥ç¥ó¤ò¥»¥Ã¥È¤¹¤ë¡£ Ê£¿ô¹Ô¤Î¥³¥Þ¥ó¥É¤Ï²þ¹Ô¤ÎÁ°¤Ë¥Ð¥Ã¥¯¥¹¥é¥Ã¥·¥å¤ò¤Ä¤±¤ë¤³¤È¤ÇÆþÎϲÄǽ¤Ç¤¢¤ë¡£
`V package'
¥Ñ¥Ã¥±¡¼¥¸Æâ¤ÎÁ´ÊÑ¿ô¤òɽ¼¨¤¹¤ë¡£ ¥Ç¥Õ¥©¥ë¥È¤Ï main ¥Ñ¥Ã¥±¡¼¥¸¤Ç¤¢¤ë¡£
`! number'
¥Ç¥Ð¥Ã¥°¥³¥Þ¥ó¥É¤òºÆ¼Â¹Ô¤¹¤ë¡£ ÈÖ¹æ¤ò¾Êά¤¹¤ë¤È¡¢Ä¾Á°¤Î¥³¥Þ¥ó¥É¤òºÆ¼Â¹Ô¤¹¤ë¡£
`! -number'
»ØÄꤷ¤¿¿ô¤À¤±Á°¤Ë¼Â¹Ô¤·¤¿¥³¥Þ¥ó¥É¤òºÆ¼Â¹Ô¤¹¤ë¡£
`H -number'
»ØÄꤷ¤¿¿ô¤Î¥³¥Þ¥ó¥É¤òºÇ¸å¤«¤éɽ¼¨¤¹¤ë¡£ 1 ʸ»ú¤è¤êŤ¤¥³¥Þ¥ó¥É¤Î¤ßɽ¼¨¤µ¤ì¤ë¡£ÈÖ¹æ¤ò¾Êά¤¹¤ë¤È¡¢Á´Éôɽ¼¨¤¹¤ë¡£
`q'
`^D'
½ªÎ»¡£
`command'
¥³¥Þ¥ó¥É¤ò perl ¤Îʸ¤È¤·¤Æ¼Â¹Ô¤¹¤ë¡£ ¥»¥ß¥³¥í¥ó¤ò¤Ä¤±¤Ê¤¯¤Æ¤â¼«Æ°Åª¤Ë¤Ä¤±¤é¤ì¤ë¡£
`p expr'
`print DB'OUT expr' ¤ÈƱ¤¸¡£STDOUT ¤¬¥ê¥À¥¤¥ì¥¯¥È¤µ¤ì¤Æ¤¤¤Æ¤â¡¢ ¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë
DB'OUT ¤Ï `/dev/tty' ¤Ë¥ª¡¼¥×¥ó¤µ¤ì¤Æ¤¤¤ë¡£

¥Ç¥Ð¥Ã¥¬¤ò½¤Àµ¤·¤¿¤¤¾ì¹ç¤Ï¡¢ perl ¥é¥¤¥Ö¥é¥ê¤«¤é `perldb.pl' ¤ò¥³¥Ô¡¼¤·¡¢É¬Íפ˱þ¤¸¤Æ½¤Àµ¤¹¤ë¡£ (¥³¥Þ¥ó¥É¥é¥¤¥ó¤Ë -I. ¤òÄɲ乤뤳¤È¤âɬÍפÀ¤í¤¦¡£)

`.perldb' ¤Ë½é´ü²½¥³¡¼¥É¤ò½ñ¤¯¤³¤È¤Ë¤è¤Ã¤Æ¥«¥¹¥¿¥Þ¥¤¥º¤¬¤Ç¤­¤ë¡£ Î㤨¤Ð¡¢¼¡¤Î¤è¤¦¤Ë¤·¤Æ¥¨¥¤¥ê¥¢¥¹¤òÄêµÁ¤Ç¤­¤ë¡£

$DB'alias{'len'} = 's/^len(.*)/p length($1)/';
$DB'alias{'stop'} = 's/^stop (at|in)/b/';
$DB'alias{'.'} =
's/^\e./p "\e$DB\e'sub(\e$DB\e'line):\et",\e$DB\e'line[\e$DB\e'line]/';

Setuid ¥¹¥¯¥ê¥×¥È

perl ¤Ï°ÂÁ´¤Ê setuid¡¦setgid ¥¹¥¯¥ê¥×¥È¤ò °ÂÁ´¤Ë½ñ¤¯¤³¤È¤¬¤Ç¤­¤ë¤è¤¦¤ËÀ߷פµ¤ì¤Æ¤¤¤ë¡£ ¥·¥§¥ë¤Ï¡¢¥¹¥¯¥ê¥×¥È¤Î³Æ¹Ô¤òÊ£¿ô¤ÎÃÖ´¹¤Î¥Ñ¥¹¤òÄ̤·¤Æ¼Â¹Ô¤¹¤ë¤¬¡¢ perl¤Ï¤è¤êÅÁÅýŪ¤Êɾ²ÁË¡¤òÍѤ¤¤Æ¡¢ ±£¤ì¤¿"¤ï¤±¤Î¤ï¤«¤é¤Ê¤¤¤â¤Î"¤ò¾¯¤Ê¤¯¤·¤Æ¤¤¤ë¡£

¤µ¤é¤Ë¡¢perl ¤Ë¤Ï¤è¤ê¿¤¯¤Î¥Ó¥ë¥È¥¤¥ó´Ø¿ô¤¬¤¢¤ë¤Î¤Ç¡¢ ÌÜŪ¤ò㤹¤ë¤¿¤á¤Ë³°Éô¤Î(¤½¤·¤Æ¿ʬ¿®ÍѤǤ­¤Ê¤¤)¥×¥í¥°¥é¥à¤ËÍê¤ëɬÍפ¬¾¯¤Ê¤¤¡£

¥Ñ¥Ã¥Á¤òÅö¤Æ¤Æ¤¤¤Ê¤¤ 4.2 ¤ä 4.3bsd ¥«¡¼¥Í¥ë¤Ç¤Ï¡¢ setuid ¥¹¥¯¥ê¥×¥È¤Ï´í¸±¤Ç¤¢¤ë¤È¸«¤Ê¤µ¤ì¤ë¤¬¡¢ ¤³¤Î¥«¡¼¥Í¥ë¤Îµ¡Ç½¤Ï»ÈÍÑÉԲĤˤ¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£

¤½¤¦¤·¤Æ¤¢¤ë¾ì¹ç¡¢perl ¤Ï setuid¡¦setgid µ¡¹½¤ò¥¨¥ß¥å¥ì¡¼¥È¤·¡¢Æ±»þ¤Ë¡¢ ¤½¤¦¤Ç¤Ê¤¤¾ì¹ç¤Ë¤Ï¥¹¥¯¥ê¥×¥È¤Ë¤Ä¤¤¤Æ¤¤¤ë setuid/gid ¥Ó¥Ã¥È¤Ï °ÕÌ£¤Î¤Ê¤¤¤â¤Î¤Ç¤¢¤ë¤³¤È¤òÃΤ餻¤ë¡£

¥«¡¼¥Í¥ë¤Îµ¡Ç½¤¬»ÈÍÑÉԲĤˤʤäƤ¤¤Ê¤¤¾ì¹ç¡¢ perl ¤Ï setuid ¥¹¥¯¥ê¥×¥È¤¬´í¸±¤Ç¤¢¤ë¤³¤È¤òÀ¼¹â¤ËÃí°Õ¤¹¤ë¡£ ¥«¡¼¥Í¥ë¤Î setuid ¥¹¥¯¥ê¥×¥Èµ¡Ç½¤ò»ÈÍÑÉԲĤˤ¹¤ë¤«¡¢ ¥¹¥¯¥ê¥×¥È¤Ë C ¤Î¥é¥Ã¥×¤ò¤«¤±¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£

perl ¤¬ setuid ¥¹¥¯¥ê¥×¥È¤ò¼Â¹Ô¤¹¤ë»þ¤Ï¡¢ ÌÀ¤é¤«¤Ê¥È¥é¥Ã¥×¤Ë¤Ï¤Þ¤é¤Ê¤¤¤è¤¦¤ÊͽËɺö¤ò¼è¤ë¡£ (´ö¤Ä¤«¤ÎÅÀ¤Ç¡¢perl ¥¹¥¯¥ê¥×¥È¤ÏƱ¤¸ÆâÍƤΠC ¥×¥í¥°¥é¥à¤è¤ê¤â°ÂÁ´¤Ç¤¢¤ë¡£)

¥³¥Þ¥ó¥É¥é¥¤¥ó°ú¿ô¡¢´Ä¶­ÊÑ¿ô¡¢ÆþÎϤϤ¹¤Ù¤Æ"±ø¤ì¤Æ¤¤¤ë"¤È¸«¤Ê¤µ¤ì¡¢ ¥µ¥Ö¥·¥§¥ë¤òµ¯Æ°¤¹¤ë¥³¥Þ¥ó¥É¤ä¡¢ ¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥ì¥¯¥È¥ê¡¦¥×¥í¥»¥¹¤òÊѹ¹¤¹¤ë¥³¥Þ¥ó¥É¤Ë¤Ï¡¢ ľÀÜŪ¤Ç¤¢¤ì´ÖÀÜŪ¤Ç¤¢¤ì¡¢»ÈÍѤ¬µö¤µ¤ì¤Ê¤¤¡£

²áµî¤Ë"±ø¤ì¤¿"Ãͤò»²¾È¤·¤¿ expression ¤Ç¥»¥Ã¥È¤µ¤ì¤¿ÊÑ¿ô¤â¤Þ¤¿ "±ø¤ì¤ë"("±ø¤ì¤¿"Ãͤ¬ÊÑ¿ô¤Ë±Æ¶Á¤òµÚ¤Ü¤¹¤³¤È¤¬ÏÀÍýŪ¤ËÉÔ²Äǽ¤Ç¤¢¤Ã¤Æ¤â)¡£

Î㤨¤Ð:

$foo = shift;            # $foo ¤Ï±ø¤ì¤Æ¤¤¤ë
$bar = $foo,'bar';       # $bar ¤â¤Þ¤¿±ø¤ì¤ë
$xxx = <>;               # ±ø¤ì¤Æ¤¤¤ë
$path = $ENV{'PATH'};    # ±ø¤ì¤Æ¤¤¤ë¤¬¡¢²¼¤ò¸«¤è
$abc = 'abc';            # ±ø¤ì¤Æ¤¤¤Ê¤¤

system "echo $foo";      # ´í¸±
system "/bin/echo", $foo;# °ÂÁ´(sh ¤Ï»È¤ï¤Ê¤¤)
system "echo $bar";      # ´í¸±
system "echo $abc";      # PATH ¤¬¥»¥Ã¥È¤µ¤ì¤Ê¤¤¤«¤®¤ê´í¸±

$ENV{'PATH'} = '/bin:/usr/bin';
$ENV{'IFS'} = " if $ENV{'IFS'} ne ";

$path = $ENV{'PATH'};    # ±ø¤ì¤Æ¤¤¤Ê¤¤
system "echo $abc";      # º£Å٤ϰÂÁ´!

open(FOO,"$foo");        # OK
open(FOO,">$foo");       # OK ¤Ç¤Ï¤Ê¤¤

open(FOO,"echo $foo|");  # OK ¤Ç¤Ï¤Ê¤¤¤¬...
open(FOO,"-|") || exec 'echo', $foo;    # OK

$zzz = `echo $foo`;      # ´í¸±¡¢zzz ¤Ï±ø¤ì¤ë

unlink $abc,$foo;        # ´í¸±
umask $foo;              # ´í¸±

exec "echo $foo";        # ´í¸±
exec "echo", $foo;       # °ÂÁ´(sh ¤Ï»È¤ï¤Ê¤¤)
exec "sh", '-c', $foo;   # °ÂÁ´¤È¤ß¤Ê¤µ¤ì¤ë¡¢¤¢¤¢

"±ø¤ì"¤ÏÁ´¥¹¥«¥é¡¼Ãͤȷë¹ç¤·¤Æ¤ª¤ê¡¢ ÇÛÎó¤Î´ö¤Ä¤«¤ÎÍ×ÁǤÏ"±ø¤ì¤Æ"¤¤¤Æ¤â¾¤ÎÍ×ÁǤÏÂç¾æÉס¢¤È¤¤¤¦¤³¤È¤â²Äǽ¤Ç¤¢¤ë¡£

²¿¤«´í¸±¤Ê¤³¤È¤ò¤·¤è¤¦¤È¤¹¤ë¤È¡¢ `Insecure dependency' ¤Þ¤¿¤Ï `Insecure PATH' ¤È¤¤¤¦¥á¥Ã¥»¡¼¥¸¤È¶¦¤Ë Ã×̿Ū¤Ê¥¨¥é¡¼¤È¤Ê¤ë¡£ ¤½¤ì¤Ç¤â´í¸±¤Ê¥·¥¹¥Æ¥à¥³¡¼¥ë¤ä exec ¤ò½ñ¤¯¤³¤È¤Ï¤Ç¤­¤ë¤¬¡¢ ¤½¤ì¤Ï¾å¤ÎºÇ¸å¤ÎÎã¤Î¤è¤¦¤ÊÌÀ¤é¤«¤Ê¾ì¹ç¤Î¤ß¤Ç¤¢¤ë¤³¤È¤ËÃí°Õ¡£

¤Þ¤¿¡¢"±ø¤ì"µ¡¹½¤ò¥µ¥Ö¥Ñ¥¿¡¼¥ó¤ò»²¾È¤¹¤ë¤³¤È¤Ç²óÈò¤¹¤ë¤³¤È¤â¤Ç¤­¤ë¡£ perl ¤Ï $1¡¢$2 ¤Ê¤É¤ò»È¤Ã¤Æ¥µ¥Ö¥¹¥È¥ê¥ó¥°¤ò»²¾È¤¹¤ë¾ì¹ç¤Ë¤Ï ¥Ñ¥¿¡¼¥ó¤ò½ñ¤¤¤¿¿Í¤¬²¿¤ò¤ä¤Ã¤Æ¤¤¤ë¤Î¤«¤òÃΤäƤ¤¤ë¤â¤Î¤À¤È²¾Äꤷ¤Æ¤¤¤ë¡£

$ARGV[0] =~ /^-P(\w+)$/;
$printer = $1;      # ±ø¤ì¤Æ¤¤¤Ê¤¤

\w+ ¤Ï¥·¥§¥ë¤Î¥á¥¿¥­¥ã¥é¥¯¥¿¤Ë¥Þ¥Ã¥Á¤·¤Ê¤¤¤Î¤Ç¡¢ ¤³¤ì¤Ï¤«¤Ê¤ê°ÂÁ´¤Ç¤¢¤ë¡£ .+ ¤ò»È¤Ã¤Æ¤¤¤¿¤é´í¸±¤Ç¤¢¤Ã¤¿¤À¤í¤¦¤¬¡¢perl ¤Ï¤½¤ì¤ò¥Á¥§¥Ã¥¯¤·¤Ê¤¤¤Î¤Ç¡¢ ¥Ñ¥¿¡¼¥ó¤Ë¤ÏÃí°Õ¤¹¤ë¤Ù¤­¤Ç¤¢¤ë¡£ ¤³¤ì¤Ï¡¢¥Õ¥¡¥¤¥ëÁàºî¤ò¹Ô¤¦¾ì¹ç¤Ë¥æ¡¼¥¶¤¬Í¿¤¨¤ë¥Õ¥¡¥¤¥ë̾¤ò"±ø¤µ¤Ê¤¤"¤¿¤á¤Î Í£°ì¤Îµ¡¹½¤Ç¤¢¤ë¡£ ($> ¤ò $< ¤ÈƱ¤¸¤Ë¤·¤Ê¤¤¤«¤®¤ê¡£)

"±ø¤ì¤¿"Ãͤòµ¤¤Ë¤«¤±¤Ê¤¤Â¾¤ÎÁàºî¤Ë¤ª¤¤¤Æ¤â¥È¥é¥Ö¥ë¤òµ¯¤³¤·ÆÀ¤ë¡£ ¥æ¡¼¥¶¤¬Í¿¤¨¤ë¥Õ¥¡¥¤¥ë̾¤ò»È¤Ã¤Æ¥Õ¥¡¥¤¥ë¥Æ¥¹¥È¤ò¤¹¤ë¾ì¹ç¤Ë¤Ï¡¢ ¤è¤¯¹Í¤¨¤ë¤è¤¦¤Ë¡£ ²Äǽ¤Ê¤é¤Ð¡¢ $> = $< ¤È¤·¤¿¸å¤Ç open ¤Ê¤É¤ò¹Ô¤Ã¤¿Êý¤¬¤¤¤¤¡£ perl ¤Ï"±ø¤ì¤¿"̾Á°¤Î¥Õ¥¡¥¤¥ë¤òÆɤ߹þ¤ß¤Î¤¿¤á¤Ë open ¤¹¤ë¤³¤È¤òµö¤¹¡£ ¤·¤¿¤¬¤Ã¤Æ¡¢½ÐÎϤ¹¤ëÆâÍƤˤÏÃí°Õ¤¹¤ë¤³¤È¡£ $> ¤Ë¤Ä¤¤¤Æ¤Ï @xref{$right,,@tt{$>}}, ¤ª¤è¤Ó $< ¤Ë¤Ä¤¤¤Æ¤Ï @xref{$left,,@tt{$<}}.

"±ø¤ì"µ¡¹½¤ÏÇϼ¯¤²¤¿´Ö°ã¤¤¤òËɤ°¤¿¤á¤Ëºî¤Ã¤¿¤â¤Î¤Ç¡¢ ²¿¤â¹Í¤¨¤Ê¤¯¤Æ¤â¤è¤¤¤è¤¦¤Ë¤¹¤ë¤¿¤á¤Î¤â¤Î¤Ç¤Ï¤Ê¤¤¡£

´Ä¶­ÊÑ¿ô

`HOME'
chdir ¤Ë°ú¿ô¤¬¤Ê¤¤»þ»ÈÍѤµ¤ì¤ë¡£
`LOGDIR'
chdir ¤Ë°ú¿ô¤¬¤Ê¤¯¡¢¤«¤Ä HOME ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤»þ»ÈÍѤµ¤ì¤ë¡£
`PATH'
¥µ¥Ö¥×¥í¥»¥¹¤ò¼Â¹Ô¤¹¤ëºÝ ¤ª¤è¤Ó -S ¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¥¹¥¯¥ê¥×¥È¤òõ¤¹ºÝ¤Ë»ÈÍѤ¹¤ë¡£
`PERLLIB'
¥³¥ó¥Þ¤Ç¶èÀÚ¤é¤ì¤¿¥Ç¥£¥ì¥¯¥È¥ê¤Î¥ê¥¹¥È¤Ç¡¢ Perl ¥é¥¤¥Ö¥é¥ê¥Õ¥¡¥¤¥ë¤òõ¤¹ºÝ¤Ë ɸ½à¥Ç¥£¥ì¥¯¥È¥ê¤ª¤è¤Ó¥«¥ì¥ó¥È¥Ç¥£¥ì¥¯¥È¥ê¤òõ¤¹Á°¤Ë»ÈÍѤ¹¤ë¡£
`PERLDB'
¥Ç¥Ð¥Ã¥¬¥³¡¼¥É¤òÆÀ¤ë¤Î¤Ë»È¤¦¥³¥Þ¥ó¥É¤ò»ØÄꤹ¤ë¡£¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢
require 'perldb.pl'
¤ò»ÈÍѤ¹¤ë¡£

¼Â¹Ô»þ¤Ë¥¹¥¯¥ê¥×¥È¤ª¤è¤Ó»Ò¥×¥í¥»¥¹¤«¤é´Ä¶­ÊÑ¿ô¤ò»ÈÍѲÄǽ¤Ë¤¹¤ë¤³¤È¤ò½ü¤¤¤Æ¡¢ perl ¤Ï¤³¤ì¤é°Ê³°¤Î´Ä¶­ÊÑ¿ô¤òÍѤ¤¤Ê¤¤¡£ ¤·¤«¤·¡¢setuid ¤µ¤ì¤¿¥¹¥¯¥ê¥×¥È¤Ç¤Ï¡¢ ÍÑ¿´¤·¤Æ²¿¤è¤ê¤âºÇ½é¤Ëɬ¤º°Ê²¼¤Î¹Ô¤ò¼Â¹Ô¤¹¤ë¤Î¤¬¤è¤¤¤À¤í¤¦¡£ ¤³¤ì¤Ï¥æ¡¼¥¶¤Ë±³¤ò¤Ä¤«¤»¤Ê¤¤¤¿¤á¤Ç¤¢¤ë(just to keep people honest)¡£

$ENV{'PATH'} = '/bin:/usr/bin';    # or whatever you need
$ENV{'SHELL'} = '/bin/sh' if $ENV{'SHELL'} ne ";
$ENV{'IFS'} = " if $ENV{'IFS'} ne ";

perl ¤Îºî¼Ô

Larry Wall <lwall@netlabs.com>

MS-DOS ¥µ¥Ý¡¼¥È¤Ï Diomidis Spinellis <dds@cc.ic.ac.uk>

perl ¤¬»ÈÍѤ¹¤ë¥Õ¥¡¥¤¥ë

-e ¥ª¥×¥·¥ç¥ó¤ò¤Ä¤±¤¿»þ¤Ë»ÈÍѤ¹¤ë¥Æ¥ó¥Ý¥é¥ê¥Õ¥¡¥¤¥ë

/tmp/perl-eXXXXXX

¿ÇÃÇ

¥³¥ó¥Ñ¥¤¥ë¥¨¥é¡¼¤Ï¥¨¥é¡¼¤Îµ¯¤³¤Ã¤¿¹ÔÈÖ¹æ¤Ë²Ã¤¨¤Æ¡¢ ¼¡¤Ë²òÀϤµ¤ì¤ë¤Ï¤º¤À¤Ã¤¿¥È¡¼¥¯¥ó¤Þ¤¿¤Ï¥È¡¼¥¯¥ó¤Î¼ïÎà¤ò¶µ¤¨¤Æ¤¯¤ì¤ë¡£ (-e ¥ª¥×¥·¥ç¥ó¤òÄ̤·¤Æ perl ¤ËÅϤµ¤ì¤ë¥¹¥¯¥ê¥×¥È¤Î¾ì¹ç¤Ï¡¢ ³Æ¡¹¤Î -e ¤¬ 1 ¹Ô¤È¿ô¤¨¤é¤ì¤ë¡£)

¤µ¤é¤Ë Setuid ¥¹¥¯¥ê¥×¥È¤Î¾ì¹ç¤Ë¤Ï¡¢ `Insecure dependency' ¤Î¤è¤¦¤Ê¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤òµ¯¤³¤¹¾ì¹ç¤¬¤¢¤ë¡£ Setuid ¥¹¥¯¥ê¥×¥È¤Î¹à¤ò»²¾È¡£ See section Setuid ¥¹¥¯¥ê¥×¥È.

Ãí°ÕÅÀ

awk ¤Ë´·¤ì¤¿¿Í¤¬ÆäËÃí°Õ¤¹¤Ù¤­ÅÀ

C ¤ËÀöǾ¤µ¤ì¤¿¥×¥í¥°¥é¥Þ¤¬ÆäËÃí°Õ¤¹¤Ù¤­ÅÀ

Ã䨤é¤ì¤¿ sed ¥×¥í¥°¥é¥Þ¤¬ÆäËÃí°Õ¤¹¤Ù¤­ÅÀ

±Ô¤¤ shell ¥×¥í¥°¥é¥Þ¤¬ÆäËÃí°Õ¤¹¤Ù¤­ÅÀ

ÄûÀµ¤ª¤è¤ÓÄɲÃ

Perl ¤ÎËÜ¡¢Programming Perl ¤Ç¤Ï ¼¡¤Î¹àÌܤò¾Êά¤¢¤ë¤¤¤ÏÆþ¤ì»¤Ê¤Ã¤Æ¤¤¤ë¡£

¥Ð¥°

perl ¤Ï·¿¥­¥ã¥¹¥Æ¥£¥ó¥°¡¢atof()¡¢sprintf() ¤Ê¤É¤Î ¤µ¤Þ¤¶¤Þ¤ÊÁàºî¤Ë¤Ä¤¤¤Æ¡¢¤¢¤Ê¤¿¤Î¥Þ¥·¥ó¤ÎÄêµÁ¤ò»È¤Ã¤Æ¤¤¤ë¡£

stdio ¤¬¤¢¤ë¥¹¥È¥ê¡¼¥à¤Î read ¤È write ¤Î´Ö¤Ë¡¢ seek ¤Þ¤¿¤Ï eof ¤òɬÍפȤ·¤Æ¤¤¤ë¤Ê¤é perl ¤â¤½¤¦¤Ê¤ë¡£ (¤³¤ì¤Ï sysread() ¤ª¤è¤Ó syswrite() ¤Ë¤Ï¤¢¤Æ¤Ï¤Þ¤é¤Ê¤¤¡£)

¤É¤Î¥Ç¡¼¥¿¥¿¥¤¥×¤Ë¤â·è¤Þ¤Ã¤¿¥µ¥¤¥º¤Î¾å¸Â¤Ï¤Ê¤¤¤¬(¥á¥â¥ê¥µ¥¤¥º¤ÏÊÌ)¡¢ ¤½¤ì¤Ç¤â¤¤¤¯¤Ä¤«¤Î¸Â³¦¤¬¤¢¤ë¡£

perl ¤Ï¼ÂºÝ¤Î½ê¤Ï¡¢`Pathologically Eclectic Rubbish Lister' (ÉÂÍý³ØŪÀÞÃï¼çµÁ¤¯¤º¥ê¥¹¥¿¡¼)¤Îά¤Ç¤¢¤ë¤¬¡¢ »ä¤¬¤½¤¦¸À¤Ã¤¿¤È¤¤¤¦¤³¤È¤Ï¤À¤ì¤Ë¤â¸À¤ï¤Ê¤¤¤Ç¤Û¤·¤¤¡£

³µÇ°/ÍѸ쥤¥ó¥Ç¥Ã¥¯¥¹

#

  • #! ¥á¥«¥Ë¥º¥à
  • $

  • $#
  • &

  • &
  • +

  • ++±é»»»Ò[++¤¨¤ó¤¶¤ó¤·]
  • <

  • <<
  • <>
  • `

  • ` `
  • c

  • continue
  • e

  • else
  • elsif
  • f

  • for
  • foreach
  • i

  • if
  • n

  • non-blocking wait
  • p

  • perl ¥Ç¥Ð¥Ã¥¬[perl ¤Ç¤Ð¤Ã¤¬]
  • picture
  • s

  • Setuid ¥¹¥¯¥ê¥×¥È[Setuid ¤¹¤¯¤ê¤×¤È]
  • System V IPC
  • w

  • while
  • ¥

  • ¥¨¥é¡¼¥¹¥Æ¡¼¥¿¥¹[¤¨¤é¤¹¤Æ¤¤¤¿¤¹]
  • ¥ª¡¼¥È¥¹¥×¥ê¥Ã¥È¥â¡¼¥É[¤ª¤È¤¹¤×¤ê¤Ã¤È¤â¤É]
  • ¥³¥¢¥À¥ó¥×[¤³¤¢¤À¤ó¤×]
  • ¥³¥Þ¥ó¥É¤Î½ÐÎÏ[¤³¤Þ¤ó¤É¤Î¤·¤å¤Ä¤ê¤ç¤¯]
  • ¥³¥Þ¥ó¥É¥é¥¤¥ó°ú¿ô[¤³¤Þ¤ó¤É¤é¤¤¤ó¤Ò¤­¤¹¤¦]
  • ¥µ¥Ö¥ë¡¼¥Á¥ó[¤µ¤Ö¤ë¤Á¤ó]
  • ¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é[¤·¤°¤Ê¤ë¤Ï¤ó¤É¤é]
  • ¥·¥¹¥Æ¥à¥¨¥é¡¼[¤·¤¹¤Æ¤à¤¨¤é]
  • ¥·¥ó¥¿¥Ã¥¯¥¹¥¨¥é¡¼[¤·¤ó¤¿¤Ã¤¯¤¹¤¨¤é]
  • ¥¹¥«¥é¡¼[¤¹¤«¤é¡¼]
  • ¥¹¥«¥é¡¼ÇÛÎó[¤¹¤«¤é¡¼¤Ï¤¤¤ì¤Ä]
  • ¥¹¥¯¥ê¥×¥È̾[¤¹¤¯¤ê¤×¤È¤á¤¤]
  • ¥¹¥¿¥Ã¥¯¥È¥ì¡¼¥¹[¤¹¤¿¤Ã¤¯¤È¤ì¤¹]
  • ¥Ç¥Ð¥Ã¥¬[¤Æ¤Ï¤Ã¤¬]
  • ¥Ç¥Ð¥Ã¥°¥Õ¥é¥°[¤Æ¤Ð¤Ã¤°¤Õ¤é¤°]
  • ¥Ç¥Ð¥Ã¥°¥â¡¼¥É[¤Æ¤Ð¤Ã¤°¤â¤É]
  • ¥Ì¥ë¥ê¥¹¥È[¤Ì¤ë¤ê¤¹¤È]
  • ¥Ì¥ëʸ»úÎó[¤Ì¤ë¤â¤¸¤ì¤Ä]
  • ¥Ñ¥Ã¥±¡¼¥¸[¤Ï¤Ã¤±¤¸]
  • ¥Õ¥¡¥¤¥ë¥Æ¥¹¥È[¤Õ¤¡¤¤¤ë¤Æ¤¹¤È]
  • ¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë[¤Õ¤¡¤¤¤ë¤Ï¤ó¤É¤ë]
  • ¥Õ¥¡¥¤¥ë̾ÃÖ´¹[¤Õ¤¡¤¤¤ë¤á¤¤¤Á¤«¤ó]
  • ¥Õ¥©¡¼¥Þ¥Ã¥È[¤Õ¤©¤Þ¤Ã¤È]
  • ¥×¥í¥°¥é¥ß¥ó¥°¥¹¥¿¥¤¥ë[¤Õ¤í¤°¤é¤ß¤ó¤°¤¹¤¿¤¤¤ë]
  • ¥×¥í¥»¥¹´ÖÄÌ¿®[¤Õ¤í¤»¤¹¤«¤ó¤Ä¤¦¤·¤ó]
  • ¥×¥í¥»¥¹ÈÖ¹æ[¤Õ¤í¤»¤¹¤Ð¤ó¤´¤¦]
  • ¥Ú¡¼¥¸¥È¥Ã¥×̾[¤Ø¤¸¤È¤Ã¤×¤á¤¤]
  • ¥Ú¡¼¥¸»Ä¤ê¹Ô¿ô[¤Ø¤¸¤Î¤³¤ê¤®¤ç¤¦¤¹¤¦]
  • ¥Ú¡¼¥¸Ä¹¤µ[¤Ø¤¸¤Ê¤¬¤µ]
  • ¥Ú¡¼¥¸ÈÖ¹æ[¤Ø¤¸¤Ð¤ó¤´¤¦]
  • ¥ì¥Ý¡¼¥È¥Õ¥©¡¼¥Þ¥Ã¥È̾[¤ì¤Ý¤È¤Õ¤©¤Þ¤Ã¤È¤á¤¤]
  • ·

  • ·ë¹çµ¬Â§[¤±¤Ä¤´¤¦¤­¤½¤¯]
  • ¹

  • ¹Ôñ°Ì¤Î°úÍÑË¡[¤­¤ç¤¦¤¿¤ó¤¤¤Î¤¤¤ó¤è¤¦¤Û¤¦]
  • ¹ÔÈÖ¹æ[¤­¤ç¤¦¤Ð¤ó¤´¤¦]
  • »

  • »²¾È¸Æ¤Ó½Ð¤·[¤µ¤ó¤·¤ç¤¦¤è¤Ó¤À¤·]
  • »Ø¿ô±é»»[¤·¤¹¤¦¤¨¤ó¤¶¤ó]
  • ½

  • ½ÐÎÏ¥Õ¥©¡¼¥Þ¥Ã¥È(¿ô»ú)[¤·¤å¤Ä¤ê¤ç¤¯¤Õ¤©¤Þ¤Ã¤È(¤¹¤¦¤¸)]
  • ½ÐÎÏ¥Õ¥é¥Ã¥·¥å[¤·¤å¤Ä¤ê¤ç¤¯¤Õ¤é¤Ã¤·¤å]
  • ½ÐÎϥ쥳¡¼¥É¥»¥Ñ¥ì¡¼¥¿(¹àÌÜ´Ö)[¤·¤å¤Ä¤ê¤ç¤¯¤ì¤³¤É¤»¤Ñ¤ì¤¿(¤³¤¦¤â¤¯¤«¤ó)]
  • ½ÐÎϥ쥳¡¼¥É¥»¥Ñ¥ì¡¼¥¿(ʸ»úÎó¤ÎºÇ¸å)[¤·¤å¤Ä¤ê¤ç¤¯¤ì¤³¤É¤»¤Ñ¤ì¤¿(¤â¤¸¤ì¤Ä¤Î¤µ¤¤¤´)]
  • ½ÐÎϥ쥳¡¼¥É¥Õ¥©¡¼¥Þ¥Ã¥È[¤·¤å¤Ä¤ê¤å¤¯¤ì¤³¤É¤Õ¤©¤Þ¤Ã¤È]
  • ¿

  • ¿ôÃÍ[¤¹¤¦¤Á]
  • À

  • Àµµ¬É½¸½[¤»¤¤¤­¤Ò¤ç¤¦¤²¤ó]
  • Á

  • ÁàºîÂоÝʸ»úÎó¤Î»ØÄê[¤½¤¦¤µ¤¿¤¤¤·¤ç¤¦¤â¤¸¤ì¤Ä¤Î¤·¤Æ¤¤]
  • Â

  • ¿¼¡¸µÇÛÎó[¤¿¤¸¤²¤ó¤Ï¤¤¤ì¤Ä]
  • Ã

  • Ã͸ƤӽФ·[¤¢¤¿¤¤¤è¤Ó¤À¤·]
  • Æ

  • ÆþÎϥ쥳¡¼¥É¥»¥Ñ¥ì¡¼¥¿[¤Ë¤å¤¦¤ê¤ç¤¯¤ì¤³¤É¤»¤Ñ¤ì¤¿]
  • Ç

  • ÇÛÎó[¤Ï¤¤¤ì¤Ä]
  • ÇÛÎó¤ÎŤµ[¤Ï¤¤¤ì¤Ä¤Î¤Ê¤¬¤µ]
  • ÇÛÎó¤Îɽ¸½[¤Ï¤¤¤ì¤Ä¤Î¤Ò¤ç¤¦¤²¤ó]
  • ÇÛÎóÃͤλ²¾È¸Æ¤Ó½Ð¤·[¤Ï¤¤¤ì¤Ä¤Á¤Ø¤Î¤µ¤ó¤·¤ç¤¦¤è¤Ó¤À¤·]
  • ÇÛÎ󟤨»ú[¤Ï¤¤¤ì¤Ä¤½¤¨¤¸]
  • Ê

  • Ê£¿ô¹Ô¥Þ¥Ã¥Á¥ó¥°[¤Õ¤¯¤¹¤¦¤®¤ç¤¦¤Þ¤Ã¤Á¤ó¤°]
  • ʸ»úÎó[¤â¤¸¤ì¤Ä]
  • ʸ»úÎó·ë¹ç[¤â¤¸¤ì¤Ä¤±¤Ä¤´¤¦]
  • ʸ»úÎóÈæ³Ó[¤â¤¸¤ì¤Ä¤Ò¤«¤¯]
  • ʸˡ¥Á¥§¥Ã¥¯[¤Õ¤ó¤Ý¤¦¤Á¤§¤Ã¤¯]
  • Ì

  • ̾Á°¶õ´Ö[¤Ê¤Þ¤¨¤¯¤¦¤«¤ó]
  • Í

  • Í¥ÀèÅÙ[¤æ¤¦¤»¤ó¤É]
  • ͽÌóÊÑ¿ô[¤è¤ä¤¯¤Ø¤ó¤¹¤¦]
  • Ï

  • Ï¢ÁÛÇÛÎó[¤ì¤ó¤½¤¦¤Ï¤¤¤ì¤Ä]
  • ´Ø¿ô¥¤¥ó¥Ç¥Ã¥¯¥¹

    !

  • !~
  • &

  • &
  • (

  • ()
  • *

  • **
  • **=
  • +

  • ++
  • -

  • --
  • -A
  • -B
  • -b
  • -C
  • -c
  • -d
  • -e
  • -f
  • -g
  • -k
  • -l
  • -M
  • -O
  • -o
  • -p
  • -R
  • -r
  • -S
  • -s
  • -T
  • -t
  • -u
  • -W
  • -w
  • -X
  • -x
  • -z
  • .

  • .
  • ..
  • .=
  • /

  • //
  • <

  • <=>
  • =

  • =~
  • ?

  • ??
  • a

  • accept
  • alarm
  • atan2
  • b

  • bind
  • binmode
  • c

  • caller
  • chdir
  • chmod
  • chop
  • chown
  • chroot
  • close
  • closedir
  • cmp
  • connect
  • continue
  • cos
  • crypt
  • d

  • dbmclose
  • dbmopen
  • defined
  • delete
  • die
  • do
  • dump
  • e

  • each
  • else
  • elsif
  • endgrent
  • endhostent
  • endnetent
  • endprotoent
  • endpwent
  • endservent
  • eof
  • eq
  • eval
  • exec
  • exit
  • exp
  • f

  • fcntl
  • fileno
  • flock
  • for
  • foreach
  • fork
  • g

  • ge
  • getc
  • getgrent
  • getgrgid
  • getgrnam
  • gethostbyaddr
  • gethostbyname
  • gethostent
  • getlogin
  • getnetbyaddr
  • getnetbyname
  • getnetent
  • getpeername
  • getpgrp
  • getppid
  • getpriority
  • getprotobyname
  • getprotobynumber
  • getprotoent
  • getpwent
  • getpwnam
  • getpwuid
  • getservbyname
  • getservbyport
  • getservent
  • getsockname
  • getsockopt
  • gmtime
  • goto
  • grep
  • gt
  • h

  • hex
  • i

  • if
  • index
  • int
  • ioctl
  • j

  • join
  • k

  • keys
  • kill
  • l

  • last
  • le
  • length
  • link
  • listen
  • local
  • localtime
  • log
  • lstat
  • lt
  • m

  • m
  • mkdir
  • msgctl
  • msgget
  • msgrcv
  • msgsnd
  • n

  • ne
  • next
  • o

  • oct
  • open
  • opendir
  • ord
  • p

  • pack
  • picture
  • pipe
  • pop
  • print
  • printf
  • push
  • q

  • q
  • qq
  • qx
  • r

  • rand
  • read
  • readdir
  • readlink
  • recv
  • redo
  • rename
  • require
  • reset
  • return
  • reverse
  • rewinddir
  • rindex
  • rmdir
  • s

  • s
  • scalar
  • seek
  • seekdir
  • select
  • semctl
  • semget
  • semop
  • send
  • setgrent
  • sethostent
  • setnetent
  • setpgrp
  • setpriority
  • setprotoent
  • setpwent
  • setservent
  • setsockopt
  • shift
  • shmctl
  • shmget
  • shmread
  • shmwrite
  • shutdown
  • sin
  • sleep
  • socket
  • socketpair
  • sort
  • splice
  • split
  • sprintf
  • sqrt
  • srand
  • stat
  • study
  • substr
  • symlink
  • syscall
  • sysread
  • system
  • syswrite
  • t

  • tell
  • telldir
  • time
  • times
  • tr
  • truncate
  • u

  • umask
  • undef
  • unlink
  • unpack
  • unshift
  • utime
  • v

  • values
  • vec
  • w

  • wait
  • waitpid
  • wantarray
  • warn
  • while
  • write
  • x

  • x
  • x=
  • y

  • y

  • This document was generated on 10 September 1996 using the texi2html translator version 1.50.