=head1 NAME getopt, getopts - Process single-character switches with switch clustering J<< ja; getopt, getopts - スイッチの塊から1文字のスイッチを処理 >> =head1 SYNOPSIS use Getopt::Std; getopt('oDI'); # -o, -D & -I take arg. Sets $opt_* as a side effect. getopt('oDI', \%opts); # -o, -D & -I take arg. Values in %opts getopts('oif:'); # -o & -i are boolean flags, -f takes an argument # Sets $opt_* as a side effect. getopts('oif:', \%opts); # options as above. Values in %opts =head1 DESCRIPTION The getopt() function processes single-character switches with switch clustering. Pass one argument which is a string containing all switches that take an argument. For each switch found, sets $opt_x (where x is the switch name) to the value of the argument if an argument is expected, or 1 otherwise. Switches which take an argument don't care whether there is a space between the switch and the argument. J<< ja; getopt() 関数は, スイッチの塊から1文字のスイッチを処理します. 引数を取る全てのスイッチを含んだ文字列を1つの引数に渡します. 各スイッチが見つかるたびに, $opt_x (x はスイッチの名前です)に 引数があれば引数の値がそうでなければ1が設定されます. 引数を とるスイッチはスイッチと引数の間の空白文字があるかどうかを 気にしません. >> The getopts() function is similar, but you should pass to it the list of all switches to be recognized. If unspecified switches are found on the command-line, the user will be warned that an unknown option was given. J<< ja; getopts() 関数はこれを似たような物ですが, 認識するべき全ての スイッチのリストを渡す必要があります. もしコマンドライン上に 知らないスイッチが見つかったときには, ユーザに不明なスイッチが 渡されたことの警告が発せられます. >> Note that, if your code is running under the recommended C pragma, you will need to declare these package variables with "our": J<< ja; もしあなたのコードが正しく推奨通りに C プラグマの元で実行されているのであれば, "our" を使って 変数の宣言を行う必要があります: >> our($opt_x, $opt_y); For those of you who don't like additional global variables being created, getopt() and getopts() will also accept a hash reference as an optional second argument. Hash keys will be x (where x is the switch name) with key values the value of the argument or 1 if no argument is specified. J<< ja; グローバル変数が追加されることを好まない人のために, getopt() 及び getopts() は省略可能な2つめの引数としてハッシュ リファレンスを受け取ることが出来ます. ハッシュのキーは x (x は スイッチの名前です) で, キーの値は引数の値若しくは指定していなければ 1 になります. >> To allow programs to process arguments that look like switches, but aren't, both functions will stop processing switches when they see the argument C<-->. The C<--> will be removed from @ARGV. J<< ja; プログラムでスイッチのようでそうではない引数を処理するために, 両関数とも引数 C<--> を見つけるとそこで処理を中断します. C<--> は @ARGV から取り除かれます. >> =head1 C<--help> and C<--version> J<< ja; C<--help> 及び C<--version> >> If C<-> is not a recognized switch letter, getopts() supports arguments C<--help> and C<--version>. If C and/or C are defined, they are called; the arguments are the output file handle, the name of option-processing package, its version, and the switches string. If the subroutines are not defined, an attempt is made to generate intelligent messages; for best results, define $main::VERSION. J<< ja; もし C<-> がスイッチ文字と認識されていなければ, getopts() は 引数 C<--help> と C<--version> をサポートします. C 及び C が 定義されていれば, それらが呼び出されます. 引数には, 出力するファイルハンドル, オプションを処理しているパッケージの名前, そのバージョン, そしてスイッチ文字列が渡されます. 関数が未定義 だった場合には, 知的なメッセージが生成されます; よりそれっぽく するためには $main::VERSION を定義するとよいでしょう. >> If embedded documentation (in pod format, see L) is detected in the script, C<--help> will also show how to access the documentation. J<< ja; もしスクリプトの中に埋め込まれているドキュメント (pod形式, L 参照)が認識されれば, C<--help> はドキュメントに アクセスする方法も表示します. >> Note that due to excessive paranoia, if $Getopt::Std::STANDARD_HELP_VERSION isn't true (the default is false), then the messages are printed on STDERR, and the processing continues after the messages are printed. This being the opposite of the standard-conforming behaviour, it is strongly recommended to set $Getopt::Std::STANDARD_HELP_VERSION to true. J<< ja; 過度にこだわるためには, $Getopt::Std::STANDARD_HELP_VERSION が 真でなければ(デフォルトは偽です), メッセージは STDERR に表示され, メッセージが出力された後も処理は継続します. これは標準的な振る舞い と反対となることから, $Getopt::Std::STANDARD_HELP_VERSION を 真に設定することを強く推奨します. >> One can change the output file handle of the messages by setting $Getopt::Std::OUTPUT_HELP_VERSION. One can print the messages of C<--help> (without the C line) and C<--version> by calling functions help_mess() and version_mess() with the switches string as an argument. J<< ja; $Getopt::Std::OUTPUT_HELP_VERSION を設定することで出力する ファイルハンドルを変えることが出来ます. 関数 help_mess() 及び version_mess() を引数にスイッチ文字列を渡して呼び出すことで, C<--help> や C<--version> で表示されるメッセージ(C行以外)を 表示することが出来ます. >> =head1 TRANSALTE TO JAPANESE J<< ja;和訳 >> 山科 氷魚 (YAMASHINA Hio) Origlnal distribution is perl VERSION 5.8.8. Translated at 2006-10-09. J<< ja; 原典: perl VERSION 5.8.8. 翻訳日: 2006-10-09. >>