argra****@users*****
argra****@users*****
2010年 7月 24日 (土) 04:48:34 JST
Index: docs/perl/5.10.0/perlglossary.pod diff -u docs/perl/5.10.0/perlglossary.pod:1.7 docs/perl/5.10.0/perlglossary.pod:1.8 --- docs/perl/5.10.0/perlglossary.pod:1.7 Sat Jun 13 03:18:14 2009 +++ docs/perl/5.10.0/perlglossary.pod Sat Jul 24 04:48:34 2010 @@ -102,6 +102,8 @@ =item alias +(エイリアス(alias)) + =begin original A nickname for something, which behaves in all ways as though you'd @@ -421,6 +423,8 @@ =item atomic operation +(アトミックな操作(atomic operation)) + =begin original When Democritus gave the word "atom" to the indivisible bits of @@ -457,6 +461,8 @@ =item autogeneration +(自動生成(autogeneration)) + =begin original A feature of L</operator overloading> of L<objects|/object>, whereby @@ -493,6 +499,8 @@ =item autoload +(オートロード(autoload)) + =begin original To load on demand. (Also called "lazy" loading.) Specifically, to @@ -1675,6 +1683,8 @@ =item construct +(構文/構築(construct)) + =begin original As a noun, a piece of syntax made up of smaller pieces. As a @@ -7982,6 +7992,8 @@ =item tainted +(汚染された(tainted)) + =begin original Said of data derived from the grubby hands of a user and thus unsafe Index: docs/perl/5.10.0/perlopentut.pod diff -u docs/perl/5.10.0/perlopentut.pod:1.5 docs/perl/5.10.0/perlopentut.pod:1.6 --- docs/perl/5.10.0/perlopentut.pod:1.5 Sun Oct 18 04:56:40 2009 +++ docs/perl/5.10.0/perlopentut.pod Sat Jul 24 04:48:34 2010 @@ -300,12 +300,11 @@ =end original -In C, when you want to open a file using the standard I/O library, -you use the C<fopen> function, but when opening a pipe, you use the -C<popen> function. But in the shell, you just use a different redirection -character. That's also the case for Perl. The C<open> call -remains the same--just its argument differs. -(TBT) +C では、標準 I/O ライブラリを使ってファイルを開きたいときは C<fopen> を +使いますが、パイプを開くときには C<popen> 関数を使います。 +しかし、シェルでは、単に違うリダイレクト文字を使います。 +これは Perl の場合にも当てはまります。 +C<open> 呼び出しは同じままです -- 単にその引数が変わります。 =begin original @@ -316,10 +315,11 @@ =end original -If the leading character is a pipe symbol, C<open> starts up a new +先頭の文字がパイプ記号の場合、C<open> は starts up a new command and opens a write-only filehandle leading into that command. This lets you write into that handle and have what you write show up on -that command's standard input. For example: +that command's standard input. +例えば: (TBT) open(PRINTER, "| lpr -Plp1") || die "can't run lpr: $!"; @@ -335,10 +335,10 @@ =end original -If the trailing character is a pipe, you start up a new command and open a +末尾の文字がパイプの場合、you start up a new command and open a read-only filehandle leading out of that command. This lets whatever that command writes to its standard output show up on your handle for reading. -For example: +例えば: (TBT) open(NET, "netstat -i -n |") || die "can't fork netstat: $!"; @@ -380,10 +380,9 @@ =end original -If you would like to open a bidirectional pipe, the IPC::Open2 -library will handle this for you. Check out -L<perlipc/"Bidirectional Communication with Another Process"> -(TBT) +双方向パイプを開きたい場合は、IPC::Open2 ライブラリが使えます。 +L<perlipc/"Bidirectional Communication with Another Process"> を +参照してください。 =head2 The Minus File @@ -399,12 +398,10 @@ =end original -Again following the lead of the standard shell utilities, Perl's -C<open> function treats a file whose name is a single minus, "-", in a -special way. If you open minus for reading, it really means to access -the standard input. If you open minus for writing, it really means to -access the standard output. -(TBT) +再び標準シェルの機能に合わせるように、Perl の +C<open> 関数は、名前がマイナス一つ "-" だけのファイルを特別に扱います。 +読み込み用にマイナスを開くと、実際には標準入力にアクセスします。 +書き込み用にマイナスを開くと、実際には標準出力にアクセスします。 =begin original @@ -419,8 +416,8 @@ If minus can be used as the default input or default output, what happens if you open a pipe into or out of minus? What's the default command it would run? The same script as you're currently running! This is actually -a stealth C<fork> hidden inside an C<open> call. See -L<perlipc/"Safe Pipe Opens"> for details. +a stealth C<fork> hidden inside an C<open> call. +詳しくは L<perlipc/"Safe Pipe Opens"> を参照してください。 (TBT) =head2 Mixing Reads and Writes @@ -439,8 +436,9 @@ =end original -It is possible to specify both read and write access. All you do is -add a "+" symbol in front of the redirection. But as in the shell, +読み書きアクセス双方を指定することは可能です。 +必要なことはリダイレクトの前に "+" の文字を加えるだけです。 +But as in the shell, using a less-than on a file never creates a new file; it only opens an existing one. On the other hand, using a greater-than always clobbers (truncates to zero length) an existing file, or creates a brand-new one @@ -470,10 +468,12 @@ =end original -The first one won't create a new file, and the second one will always -clobber an old one. The third one will create a new file if necessary -and not clobber an old one, and it will allow you to read at any point -in the file, but all writes will always go to the end. In short, +一つ目のものは新しいファイルを作ることはなく、二つ目のものは常に古い +ファイルを上書きします。 +三つ目のものは必要があれば新しいファイルを作りますが、古いファイルを +上書きせず、ファイルのどの地点でも読み込むことができますが、 +書き込みは常に末尾に行われます。 +In short, the first case is substantially more common than the second and third cases, which are almost always wrong. (If you know C, the plus in Perl's C<open> is historically derived from the one in C's fopen(3S), @@ -492,7 +492,7 @@ =end original -In fact, when it comes to updating a file, unless you're working on +実際、when it comes to updating a file, unless you're working on a binary file as in the WTMP case above, you probably don't want to use this approach for updating. Instead, Perl's B<-i> flag comes to the rescue. The following command takes all the C, C++, or yacc source @@ -578,8 +578,9 @@ You are welcome to pre-process your @ARGV before starting the loop to make sure it's to your liking. One reason to do this might be to remove -command options beginning with a minus. While you can always roll the -simple ones by hand, the Getopts modules are good for this: +command options beginning with a minus. +いつでも自分で単純なものを作ることができる一方、 +Getopts モジュールはこれを行うのによいものです: (TBT) use Getopt::Std; @@ -596,8 +597,8 @@ =end original -Or the standard Getopt::Long module to permit named arguments: -(TBT) +あるいは、名前付きの引数を使えるようにするための +標準の Getopt::Long モジュールもあります: use Getopt::Long; GetOptions( "verbose" => \$verbose, # --verbose @@ -612,9 +613,8 @@ =end original -Another reason for preprocessing arguments is to make an empty -argument list default to all files: -(TBT) +引数を前処理するためのもう一つの理由は、空引数リストの時は +デフォルトで全てのファイルとする場合です: @ARGV = glob("*") unless @ARGV; @@ -625,9 +625,8 @@ =end original -You could even filter out all but plain, text files. This is a bit -silent, of course, and you might prefer to mention them on the way. -(TBT) +プレーンなテキストファイル以外をフィルタリングすることもできます。 +これはもちろん少し静かなので、途中でそれに言及したいかもしれません。 @ARGV = grep { -f && -T } @ARGV; @@ -638,9 +637,8 @@ =end original -If you're using the B<-n> or B<-p> command-line options, you -should put changes to @ARGV in a C<BEGIN{}> block. -(TBT) +もし B<-n> や B<-p> のコマンドラインオプションを使っているなら、 + @ ARGV への変更は C<BEGIN{}> ブロックで行うべきです。 =begin original @@ -775,8 +773,7 @@ =end original -C<sysopen> takes 3 (or 4) arguments. -(TBT) +C<sysopen> は 3 (または 4) 引数を取ります。 sysopen HANDLE, PATH, FLAGS, [MASK] @@ -871,8 +868,7 @@ =end original -To open a file for reading: -(TBT) +ファイルを読み込み用に開くには: open(FH, "< $path"); sysopen(FH, $path, O_RDONLY); @@ -884,9 +880,8 @@ =end original -To open a file for writing, creating a new file if needed or else truncating -an old file: -(TBT) +ファイルを書き込み用に開いて、必要なら新しいファイルを作り、そうでなければ +古いファイルを切り詰めるには: open(FH, "> $path"); sysopen(FH, $path, O_WRONLY | O_TRUNC | O_CREAT); @@ -897,8 +892,7 @@ =end original -To open a file for appending, creating one if necessary: -(TBT) +ファイルを追加用に開いて、もし必要なら新しいファイルを作るには: open(FH, ">> $path"); sysopen(FH, $path, O_WRONLY | O_APPEND | O_CREAT); @@ -909,8 +903,7 @@ =end original -To open a file for update, where the file must already exist: -(TBT) +既に存在しているファイルを更新用に開くには: open(FH, "+< $path"); sysopen(FH, $path, O_RDWR); @@ -1146,9 +1139,8 @@ =end original -It can be easier (and certainly will be faster) just to use real -filehandles though: -(TBT) +しかし、単に普通のファイルハンドルを使う方が簡単でしょう +(そして確実に高速です): use IO::Socket; local *REMOTE = IO::Socket::INET->new("www.perl.com:80"); @@ -1298,9 +1290,8 @@ =end original -You've probably noticed how Perl's C<warn> and C<die> functions can -produce messages like: -(TBT) +どうやって Perl の C<warn> 関数と C<die> 関数が以下のようなメッセージを +生成するかに気付いたでしょう: Some warning at scriptname line 29, <FH> line 7. @@ -1311,9 +1302,9 @@ =end original -That's because you opened a filehandle FH, and had read in seven records -from it. But what was the name of the file, rather than the handle? -(TBT) +これは、あなたがファイルハンドル FH を開いて、そこから 7 レコードを +読み込んだからです。 +しかし、ハンドルではなく、ファイル名はどうでしょう? =begin original @@ -1322,9 +1313,8 @@ =end original -If you aren't running with C<strict refs>, or if you've turned them off -temporarily, then all you have to do is this: -(TBT) +もし C<strict refs> を有効にしていないか、一時的に無効にしているなら、 +する必要があるのは以下のことだけです: open($path, "< $path") || die "can't open $path: $!"; while (<$path>) { @@ -1338,9 +1328,8 @@ =end original -Since you're using the pathname of the file as its handle, -you'll get warnings more like -(TBT) +ファイルのパス名をハンドルとして使っているので、以下のような警告が +出ます Some warning at scriptname line 29, </etc/motd> line 7. @@ -1629,7 +1618,7 @@ =end original -名前付きパイプは異なった問題です。 +名前付きパイプは別の問題です。 You pretend they're regular files, but their opens will normally block until there is both a reader and a writer. You can read more about them in L<perlipc/"Named Pipes">. @@ -1879,12 +1868,11 @@ =end original -Never use the existence of a file C<-e $file> as a locking indication, -because there is a race condition between the test for the existence of -the file and its creation. It's possible for another process to create -a file in the slice of time between your existence check and your attempt -to create the file. Atomicity is critical. -(TBT) +決して、ファイルの存在 C<-e $file> をロック指示に使わないでください; +なぜならファイルの存在のテストとその作成の間に競合条件があるからです。 +存在チェックとファイル作成のわずかな間に、他のプロセスがファイルを作る +可能性があります。 +原子性は危機的です。 =begin original @@ -1896,12 +1884,12 @@ =end original -Perl's most portable locking interface is via the C<flock> function, -whose simplicity is emulated on systems that don't directly support it -such as SysV or Windows. The underlying semantics may affect how -it all works, so you should learn how C<flock> is implemented on your -system's port of Perl. -(TBT) +Perl でのもっとも移植性のあるロックインターフェースは、 +C<flock> 関数によるものです; この単純さは、SysV や Windows のような、 +これに直接対応していないシステムでもエミュレートされています。 +基礎となる動作はこれがどのように働くかに影響を与えるので、 +あなたが使うシステムの Perl で C<flock> がどのように実装されているかを +学ぶべきです。 =begin original @@ -1912,11 +1900,12 @@ =end original -File locking I<does not> lock out another process that would like to -do I/O. A file lock only locks out others trying to get a lock, not -processes trying to do I/O. Because locks are advisory, if one process -uses locking and another doesn't, all bets are off. -(TBT) +ファイルロックは、他のプロセスが I/O 操作を行うことからロックするもの +I<ではありません>。 +ファイルロックは、他のプロセスの I/O 操作をロックするのではなく、他の +プロセスがロックを得ようとすることをロックします。 +ロックは勧告的なので、あるプロセスがロックを使っていても、他の +プロセスがロックを使っていなければ、全ては台無しになります。 =begin original @@ -1929,13 +1918,14 @@ =end original -By default, the C<flock> call will block until a lock is granted. -A request for a shared lock will be granted as soon as there is no -exclusive locker. A request for an exclusive lock will be granted as -soon as there is no locker of any kind. Locks are on file descriptors, -not file names. You can't lock a file until you open it, and you can't -hold on to a lock once the file has been closed. -(TBT) +デフォルトでは、C<flock> 呼び出しは、ロックが得られるまでブロックします。 +共有ロック要求は、誰も排他ロックを持っていない状態になれば直ちに +受け入れられます。 +排他ロック要求は、誰もあらゆる種類のロックを守っていない状態になれば +与えられます。 +ロックはファイル名に対してではなく、ファイル記述子について与えられます。 +ファイルを開かずにファイルをロックすることはできませんし、ファイルを閉じた +後もロックを持ったままにすることもできません。 =begin original @@ -1944,9 +1934,8 @@ =end original -Here's how to get a blocking shared lock on a file, typically used -for reading: -(TBT) +以下はファイルに対してブロックする共有ロックを得る方法で、 +典型的には読み込み時に使われます: use 5.004; use Fcntl qw(:DEFAULT :flock); @@ -1960,8 +1949,7 @@ =end original -You can get a non-blocking lock by using C<LOCK_NB>. -(TBT) +C<LOCK_NB> を使うことでブロックしないロックも得られます。 flock(FH, LOCK_SH | LOCK_NB) or die "can't lock filename: $!"; @@ -1973,9 +1961,8 @@ =end original -This can be useful for producing more user-friendly behaviour by warning -if you're going to be blocking: -(TBT) +ブロックするときに警告することで、よりユーザーにやさしい振る舞いを +することは有用です: use 5.004; use Fcntl qw(:DEFAULT :flock); @@ -1996,8 +1983,9 @@ =end original -To get an exclusive lock, typically used for writing, you have to be -careful. We C<sysopen> the file so it can be locked before it gets +(典型的には書き込みのために) 排他ロックを得るためには、慎重になる +必要があります。 +We C<sysopen> the file so it can be locked before it gets emptied. You can get a nonblocking version using C<LOCK_EX | LOCK_NB>. (TBT) @@ -2081,7 +2069,7 @@ =end original PerlIO の機能に関する完全な議論はこのチュートリアルの対象外ですが、 -以下は層がどのように使われているかです: +層が使われていることをどうやって認識するかを以下に示します: =over 4 @@ -2096,11 +2084,9 @@ =end original -The three-(or more)-argument form of C<open> is being used and the -second argument contains something else in addition to the usual -C<< '<' >>, C<< '>' >>, C<< '>>' >>, C<< '|' >> and their variants, -for example: -(TBT) +3 (以上) 引数形式の C<open> が使われ、2 番目の引数に通常の +C<< '<' >>, C<< '>' >>, C<< '>>' >>, C<< '|' >> およびそのバリエーション +以外の何かが含まれている場合; 例えば: open(my $fh, "<:crlf", $fn); @@ -2112,7 +2098,7 @@ =end original -2 引数形式の C<binmode> が使われています; 例えば +2 引数形式の C<binmode> が使われている場合; 例えば binmode($fh, ":encoding(utf16)");