5.14.1

名前

perlfaq - frequently asked questions about Perl

perlfaq - Perl に関するよくある質問

説明

The perlfaq comprises several documents that answer the most commonly asked questions about Perl and Perl programming. It's divided by topic into nine major sections outlined in this document.

perlfaq は、Perl と Perl プログラミングに関するもっともよくある質問へ 回答しているいくつかの文書から構成されています。 これはこの文書に概説されている、9 個の大きな区分に分割されています。

perlfaq を見るには

The perlfaq comes with the standard Perl distribution, so if you have Perl you should have the perlfaq. You should also have the perldoc tool that lets you read the perlfaq:

perlfaq は標準 Perl 配布に含まれているので、Perl があれば perlfaq も あるはずです。 perlfaq を読むには perldoc ツールもあります:

        $ perldoc perlfaq

Besides your local system, you can find the perlfaq on the web, including at http://perldoc.perl.org/ .

ローカルシステムの他に、http://perldoc.perl.org/ などの web にも perlfaq はあります。

The perlfaq is an evolving document and you can read the latest version at http://faq.perl.org/ . The perlfaq-workers periodically post extracts of the latest perlfaq to comp.lang.perl.misc.

perlfaq は発展しつつある文書で、最新版は http://faq.perl.org/ で読めます。 perlfaq-workers は定期的に最新の perlfaq の抜粋を comp.lang.perl.misc に 投稿します。

The perlfaq documents are in the perl source tree (see perlgit). The git repository notes all changes to the FAQ and holds the latest version of the working documents and may vary significantly from the version distributed with the latest version of Perl. Check the repository before sending your corrections.

perlfaq 文書は perl ソースツリー (perlgit を参照) にあります。 git リポジトリは FAQ への全ての変更を記録して、作業中の最新のバージョンを 保持しているので、Perl の最新バージョンで配布されたものと大きく 異なっているかもしれません。 修正箇所を送る前にリポジトリをチェックしてください。

perlfaq への貢献方法

You can mail corrections, additions, and suggestions to <perlfaq-workers AT perl DOT org>. The perlfaq volunteers use this address to coordinate their efforts and track the perlfaq development. They appreciate your contributions to the FAQ but do not have time to provide individual help, so don't use this address to ask FAQs.

追加、修正、提案は <perlfaq-workers AT perl DOT org> に メールしてください。 perlfaq のボランティアはこのアドレスを、作業の協調と perlfaq 開発の 記録のために使っています。 彼らはあなたの FAQ に対する貢献に感謝していますが、個々の助けを提供する 時間はないので、FAQ を尋ねるのにこのアドレスを使わないでください。

The perlfaq server posts extracts of the perlfaq to that newsgroup every 6 hours (or so), and the community of volunteers reviews and updates the answers. If you'd like to help review and update the answers, check out comp.lang.perl.misc.

perlfaq サーバは perlfaq の抜粋をニュースグループに 6 時間(ぐらい)毎に 投稿し、ボランティアのコミュニティが答えのレビューと更新を行います。 もし答えのレビューと更新を手伝いたいなら、comp.lang.perl.misc を 見てください。

You can also fork the perl repository, make your changes, and send them to Perl 5 Porters. See perlgit.

perl レポジトリを fork して、変更して、Perl 5 Porters に送ることも できます。 perlgit を参照してください。

Perl のプログラミングに関する問題を作者にメールするとどうなるの?

The perlfaq-workers like to keep all traffic on the perlfaq-workers list so that everyone can see the work being done (and the work that needs to be done). The mailing list serves as an official record. If you email the authors or maintainers directly, you'll probably get a reply asking you to post to the mailing list. If you don't get a reply, it probably means that the person never saw the message or didn't have time to deal with it. Posting to the list allows the volunteers with time to deal with it when others are busy.

perlfaq-workers は、処理されつつある作業(および処理される必要がある 作業)が全員に見えるように、全てのトラフィックが perlfaq-workers リストに 流れることを好んでいます。 このメーリングリストは公式な記録となります。 もし作者やメンテナに直接メールすると、おそらく「メーリングリストに 投稿するように」という返信を受け取るでしょう。 返信を受け取らない場合、それはおそらくその人がメッセージを読んでいないか、 それを処理する時間がないことを意味します。 メーリングリストに投稿することで、他の人が忙しい時に、時間のある人が それを扱えるようになります。

If you have a question that isn't in the FAQ and you would like help with it, try the resources in perlfaq2.

もしこの FAQ にない質問があって、それに関する助けがほしいなら、 perlfaq2 にあるリソースを試してみてください。

CREDITS

Tom Christiansen wrote the original perlfaq then expanded it with the help of Nat Torkington. The perlfaq-workers maintain current document and the denizens of comp.lang.perl.misc regularly review and update the FAQ. Several people have contributed answers, corrections, and comments, and the perlfaq notes those contributions wherever appropriate.

Tom Christiansen が最初の perlfaq を書き、Nat Torkington の助けを借りて 拡張しました。 perlfaq-workers が現在の文書を保守し、comp.lang.perl.misc の住人が定期的に FAQ のレビューと更新を行っています。 何人かの人々が回答、訂正、コメントを提供し、perlfaq は適切なものは何でも これらの貢献を記録しています。

AUTHOR AND COPYRIGHT

Tom Christiansen wrote the original version of this document. brian d foy <bdfoy@cpan.org> wrote this version. See the individual perlfaq documents for additional copyright information.

This document is available under the same terms as Perl itself. Code examples in all the perlfaq documents are in the public domain. Use them as you see fit (and at your own risk with no warranty from anyone).

目次

perlfaq - this document

(perlfaq - この文書)

perlfaq1 - General Questions About Perl

(perlfaq1 - Perl に関する一般的な質問)

perlfaq2 - Obtaining and Learning about Perl

(perlfaq2 - Perl の入手と学習)

perlfaq3 - Programming Tools

(perlfaq3 - プログラミングツール)

perlfaq4 - Data Manipulation

(perlfaq4 - データ操作)

perlfaq5 - Files and Formats

(perlfaq5 - ファイルとフォーマット)

perlfaq6 - Regular Expressions

(perlfaq6 - 正規表現)

perlfaq7 - General Perl Language Issues

(perlfaq7 - Perl 言語一般に関することがら)

perlfaq8 - System Interaction

(perlfaq8 - システムとの相互作用)

perlfaq9 - Networking

(perlfaq9 - ネットワーク)

質問

perlfaq1: General Questions About Perl

(perlfaq1: Perl に関する一般的な質問)

Very general, high-level questions about Perl.

Perl に関する非常に一般的で高レベルの質問。

  • What is Perl?

    Perlってなんですか?

  • Who supports Perl? Who develops it? Why is it free?

    だれが Perl をサポートしているのですか? 誰が開発しているのですか? なぜフリーなのでしょうか?

  • Which version of Perl should I use?

    どのバージョンの Perl を使うべきなのでしょうか?

  • What are Perl 4, Perl 5, or Perl 6?

    Perl 4, Perl 5, Perl 6 って何ですか?

  • What was Ponie?

    Ponie って何ですか?

  • What is Perl 6?

    Perl 6 ってなんですか?

  • How stable is Perl?

    Perl はどのくらい安定しているのでしょうか?

  • Is Perl difficult to learn?

    Perl は学ぶのが難しいのでしょうか?

  • How does Perl compare with other languages like Java, Python, REXX, Scheme, or Tcl?

    Java, Python, REXX, Scheme, Tcl といった他の言語と比べて Perl はどうなんでしょうか?

  • Can I do [task] in Perl?

    Perlで○○を行えますか?

  • When shouldn't I program in Perl?

    Perl でプログラムするべきではないのはどういう場合ですか?

  • What's the difference between "perl" and "Perl"?

    “perl”と“Perl”の違いはなんですか?

  • Is it a Perl program or a Perl script?

    Perl プログラム、それとも Perl スクリプト?

  • What is a JAPH?

    JAPH ってなんですか?

  • Where can I get a list of Larry Wall witticisms?

    Larry Wall の「お言葉」(witticisms) はどこで手に入れられますか?

  • How can I convince others to use Perl?

    他の人に、どうすれば Perl を使うように説得できるでしょうか?

perlfaq2: Obtaining and Learning about Perl

(perlfaq2: Perl の入手と学習)

Where to find source and documentation for Perl, support, and related matters.

Perl のソースや Perl に関するドキュメントが 手に入れられる場所に関する質問や、サポートとトレーニング、関連した 出来事に関する質問。

  • What machines support perl? Where do I get it?

    perl はどんなマシンで動きますか? どこで入手できますか?

  • How can I get a binary version of perl?

    バイナリ形式の perl はどうすれば入手できますか?

  • I don't have a C compiler. How can I build my own Perl interpreter?

    私は C コンパイラーを持っていません。どうすれば自分用の Perl インタプリタをビルドできますか?

  • I copied the perl binary from one machine to another, but scripts don't work.

    perl のバイナリをあるマシンから別のマシンにコピーしたのだけど、スクリプトが動きませんでした

  • I grabbed the sources and tried to compile but gdbm/dynamic loading/malloc/linking/... failed. How do I make it work?

    ソースを取ってきてコンパイルしようとしたのだけど、gdbm/dynamic loading/malloc/linking/... failed. となってしまった。動くようにするにはどうすればいいの?

  • What modules and extensions are available for Perl? What is CPAN? What does CPAN/src/... mean?

    Perlに使えるモジュールとかエクステンションってなんですか? CPAN ってなに? CPAN/src/... ってどういう意味なんですか?

  • Is there an ISO or ANSI certified version of Perl?

    ISO や ANSI で認証された Perl はあるの?

  • Where can I get information on Perl?

    Perl に関する情報はどこで手に入れられますか?

  • What are the Perl newsgroups on Usenet? Where do I post questions?

    Usenet にある Perl のニューズグループはなに? 質問はどこに投稿するの?

  • Where should I post source code?

    ソースコードはどこに投稿すべきなのですか?

  • Perl Books

    Perl の書籍

  • Which magazines have Perl content?

    Perl 関連の雑誌は?

  • What mailing lists are there for Perl?

    Perlのためのメイリングリストって?

  • Where are the archives for comp.lang.perl.misc?

    comp.lang.perl.misc のアーカイブはどこにありますか?

  • Where can I buy a commercial version of perl?

    どこで商用版 perl を買うことができますか?

  • Where do I send bug reports?

    バグレポートはどこへ送るの?

  • What is perl.com? Perl Mongers? pm.org? perl.org? cpan.org?

    perl.com, Perl Mongers, pm.org, perl.org, cpan.org ってなんですか?

perlfaq3: Programming Tools

(perlfaq3: プログラミングツール)

Programmer tools and programming support.

プログラマーツールやプログラミングサポート。

  • How do I do (anything)?

    ○○をするにはどうすればいいの?

  • How can I use Perl interactively?

    対話的に Perl を使うには?

  • Is there a Perl shell?

    Perl シェルはありますか?

  • How do I find which modules are installed on my system?

    自分のシステムに入っているモジュールを知るには?

  • How do I debug my Perl programs?

    私の Perl プログラムをデバッグするには?

  • How do I profile my Perl programs?

    私の Perl プログラムのプロファイルを取るには?

  • How do I cross-reference my Perl programs?

    私の Perl プログラムのクロスリファレンスをとるには?

  • Is there a pretty-printer (formatter) for Perl?

    Perl 用のプリティプリンター(フォーマッター)はありますか?

  • Is there a ctags for Perl?

    Perl 用の ctags はありますか?

  • Is there an IDE or Windows Perl Editor?

    Perl の統合開発環境とか Windows Perl Editor はありますか?

  • Where can I get Perl macros for vi?

    vi 用の Perl マクロはどこで入手できますか?

  • Where can I get perl-mode or cperl-mode for emacs?

    emacs の perl-mode や cperl-mode はどこで入手できますか?

  • How can I use curses with Perl?

    Perl で curses を使うには?

  • How can I write a GUI (X, Tk, Gtk, etc.) in Perl?

    Perl で GUI (X, Tk, Gtk など) を書くには?

  • How can I make my Perl program run faster?

    私の Perl プログラムをもっと速くするには?

  • How can I make my Perl program take less memory?

    私の Perl プログラムのメモリ消費量を少なくするには?

  • Is it safe to return a reference to local or lexical data?

    ローカルやレキシカルなデータへのポインターを返すことは安全ですか?

  • How can I free an array or hash so my program shrinks?

    配列やハッシュを解放して私のプログラムを小さくするには?

  • How can I make my CGI script more efficient?

    私の CGI スクリプトをもっと効率よくするには?

  • How can I hide the source for my Perl program?

    私の Perl プログラムのソースを隠すには?

  • How can I compile my Perl program into byte code or C?

    私の Perl プログラムをバイトコードや C へコンパイルするには?

  • How can I get #!perl to work on [MS-DOS,NT,...]?

    MS-DOS, NT, etc で '#!perl' が動作するようにするには?

  • Can I write useful Perl programs on the command line?

    コマンドライン上で便利な Perl プログラムを書けますか?

  • Why don't Perl one-liners work on my DOS/Mac/VMS system?

    なぜ私の DOS/Mac/VMS システムでは一行野郎は動かないのでしょうか?

  • Where can I learn about CGI or Web programming in Perl?

    Perl による CGI や Web プログラミングについてどこで学べますか?

  • Where can I learn about object-oriented Perl programming?

    オブジェクト指向の Perl プログラミングはどこで学べますか?

  • Where can I learn about linking C with Perl?

    C と Perl のリンクについてはどこで学べますか?

  • I've read perlembed, perlguts, etc., but I can't embed perl in my C program; what am I doing wrong?

    perlembed や perlguts なんかを読んだのだけど、私の C プログラムに perl を組み込めません。何が悪いのでしょうか?

  • When I tried to run my script, I got this message. What does it mean?

    私のスクリプトを実行したとき、こんなメッセージを受け取りました。これって何を意味しているのでしょうか?

  • What's MakeMaker?

    MakeMaker ってなんですか?

perlfaq4: Data Manipulation

(perlfaq4: データ操作)

Manipulating numbers, dates, strings, arrays, hashes, and miscellaneous data issues.

数値、日付、文字列、配列、ハッシュその他の データの取り扱い。

  • Why am I getting long decimals (eg, 19.9499999999999) instead of the numbers I should be getting (eg, 19.95)?

    なぜ 19.95 のような数字ではなく、19.9499999999999 のような長い数字が出てきたんでしょうか?

  • Why is int() broken?

    なぜ int() は壊れているのでしょう?

  • Why isn't my octal data interpreted correctly?

    なぜ私の 8 進データは正しく解釈されないのでしょうか?

  • Does Perl have a round() function? What about ceil() and floor()? Trig functions?

    Perl には丸め関数がありますか? ceil() と floor() とは何ですか? 三角関数は?

  • How do I convert between numeric representations/bases/radixes?

    数値表現や基底や基数を変換するには?

  • Why doesn't & work the way I want it to?

    なぜ & は私の思った通りに動作しないのでしょうか?

  • How do I multiply matrices?

    行列の積を計算するには?

  • How do I perform an operation on a series of integers?

    整数値の並びに対してある操作を実行するには?

  • How can I output Roman numerals?

    ローマ数字を出力するには?

  • Why aren't my random numbers random?

    なぜ私の乱数はランダムでないの?

  • How do I get a random number between X and Y?

    X と Y の間の乱数を得るには?

  • How do I find the day or week of the year?

    その年の何日目であるかを知るには?

  • How do I find the current century or millennium?

    現在の世紀や千年紀を知るには?

  • How can I compare two dates and find the difference?

    二つの日付文字列を比較するには?

  • How can I take a string and turn it into epoch seconds?

    文字列を受け取って、それを紀元からの経過秒数に変換するには?

  • How can I find the Julian Day?

    ユリウス日を求めるには?

  • How do I find yesterday's date?

    昨日の日付を得るには?

  • Does Perl have a Year 2000 or 2038 problem? Is Perl Y2K compliant?

    Perl には 2000 年問題や 2038 年問題があるのですか? Perl は 2000 年対応ですか?

  • How do I validate input?

    入力を検査するには?

  • How do I unescape a string?

    文字列のアンエスケープ (unescape)をするには?

  • How do I remove consecutive pairs of characters?

    キャラクタの連続した組を取り除くには?

  • How do I expand function calls in a string?

    文字列中にある関数呼び出しを展開するには?

  • How do I find matching/nesting anything?

    何かがマッチしている/ネストしているということを検出するには?

  • How do I reverse a string?

    文字列をひっくり返すには?

  • How do I expand tabs in a string?

    文字列中にあるタブを展開するには?

  • How do I reformat a paragraph?

    段落を整形するには?

  • How can I access or change N characters of a string?

    文字列の最初の N 文字にアクセスしたり、それを変更するには?

  • How do I change the Nth occurrence of something?

    何かの N 番目のものを変更するには?

  • How can I count the number of occurrences of a substring within a string?

    ある文字列の中に存在する部分文字列が何個あるのかを数えるには?

  • How do I capitalize all the words on one line?

    一行にあるすべての単語をキャピタライズするには?

  • How can I split a [character]-delimited string except when inside [character]?

    (とある文字)の内側にある時を除き、(とある文字)で終端されている文字列を分割するには?

  • How do I strip blank space from the beginning/end of a string?

    文字列の先頭や末尾にある空白を剥ぎ取るには?

  • How do I pad a string with blanks or pad a number with zeroes?

    文字列に空白をパッディングしたり、数値にゼロをパッディングしたりするには?

  • How do I extract selected columns from a string?

    文字列から選択されたカラムを取り出すには?

  • How do I find the soundex value of a string?

    文字列の soundex 値を見つけるには?

  • How can I expand variables in text strings?

    テキスト文字列の中にある変数を展開するには?

  • What's wrong with always quoting "$vars"?

    常にクォーティング "$vars" することの何が悪いの?

  • Why don't my <<HERE documents work?

    なぜ私の <<HERE ドキュメントがうまく動かないのでしょう?

  • What is the difference between a list and an array?

    リストと配列の差とはなんですか?

  • What is the difference between $array[1] and @array[1]?

    $array[1] と @array[1] との間の違いはなんですか?

  • How can I remove duplicate elements from a list or array?

    配列やリストにある重複した要素を削除するには?

  • How can I tell whether a certain element is contained in a list or array?

    リストや配列の内容にある特定の要素があるかどうかを確かめるには?

  • How do I compute the difference of two arrays? How do I compute the intersection of two arrays?

    二つの配列の差(difference)を求めるには? 二つの配列の共通要素(inter section)を求めるには?

  • How do I test whether two arrays or hashes are equal?

    二つの配列や二つのハッシュが等しいかどうかを検査するには?

  • How do I find the first array element for which a condition is true?

    ある条件が真となる最初の配列要素を見つけだすには?

  • How do I handle linked lists?

    リンク付きリストを扱うには?

  • How do I handle circular lists?

    循環リストを扱うには?

  • How do I shuffle an array randomly?

    配列をランダムにかき混ぜるには?

  • How do I process/modify each element of an array?

    配列の各要素に対する処理や、変更を行うには?

  • How do I select a random element from an array?

    ある配列からランダムに要素を選択するには?

  • How do I permute N elements of a list?

    N 要素を持つリストの順列(permute)を求めるには?

  • How do I sort an array by (anything)?

    (なにか)で配列をソートするには?

  • How do I manipulate arrays of bits?

    ビット配列を扱うには?

  • Why does defined() return true on empty arrays and hashes?

    なぜ空の配列やハッシュに defined() を使ったときに真が返ってくるのでしょう?

  • How do I process an entire hash?

    ハッシュ全体を処理するには?

  • How do I merge two hashes?

    二つのハッシュをマージするには?

  • What happens if I add or remove keys from a hash while iterating over it?

    ハッシュに対して反復操作を行っているときにキーの追加や削除をすると何が起きますか?

  • How do I look up a hash element by value?

    ハッシュの要素をその値で検索するには?

  • How can I know how many entries are in a hash?

    ハッシュにどれくらいの要素があるのを知るには?

  • How do I sort a hash (optionally by value instead of key)?

    ハッシュを(キーではなく値で)ソートするには?

  • How can I always keep my hash sorted?

    私のハッシュを常にソートされた状態にしておくには?

  • What's the difference between "delete" and "undef" with hashes?

    ハッシュに対する "delete" と "undef"との間の違いは?

  • Why don't my tied hashes make the defined/exists distinction?

    なぜわたしの tie されたハッシュは defined と exists を区別しないのでしょうか?

  • How do I reset an each() operation part-way through?

    each() 操作の途中でリセットしてしまうには?

  • How can I get the unique keys from two hashes?

    二つのハッシュからユニークなキーを取りだすには?

  • How can I store a multidimensional array in a DBM file?

    DBM ファイルに多次元配列を格納するには?

  • How can I make my hash remember the order I put elements into it?

    わたしのハッシュが格納した順番を覚えておくようにするには?

  • Why does passing a subroutine an undefined element in a hash create it?

    なぜあるハッシュの未定義要素をサブルーチンに渡すとそれを作成するのでしょうか?

  • How can I make the Perl equivalent of a C structure/C++ class/hash or array of hashes or arrays?

    C の構造体/C++ のクラスのハッシュ、配列のハッシュ、配列と等価なものを Perl で作成するには?

  • How can I use a reference as a hash key?

    ハッシュのキーとしてリファレンスを使うには?

  • How can I check if a key exists in a multilevel hash?

    複数レベルハッシュにキーがあるかどうかをチェックするには?

  • How do I handle binary data correctly?

    バイナリデータを正しく扱うには?

  • How do I determine whether a scalar is a number/whole/integer/float?

    あるスカラ値が数値/整数/浮動小数点数かどうかを決定するには?

  • How do I keep persistent data across program calls?

    プログラムの呼び出しの間に、データ構造を永続的に保持するには?

  • How do I print out or copy a recursive data structure?

    再帰的なデータ構造を出力したりコピーするには?

  • How do I define methods for every class/object?

    すべてのクラス/オブジェクトのためのメソッドを定義するには?

  • How do I verify a credit card checksum?

    クレジットカードのチェックサムを検査するには?

  • How do I pack arrays of doubles or floats for XS code?

    XSプログラムのために倍精度実数や単精度実数の配列を pack するには?

perlfaq5: Files and Formats

(perlfaq5: ファイルとフォーマット)

I/O and the "f" issues: filehandles, flushing, formats, and footers.

入出力と“f”に関する事柄: ファイルハンドル (filehandle)、フラッシング(flushing)、フォーマット(format)、 フッター(footer)。

  • How do I flush/unbuffer an output filehandle? Why must I do this?

    出力ファイルハンドルを flush/unbufferするには? なぜ私はこれをやらなければならないの?

  • How do I change, delete, or insert a line in a file, or append to the beginning of a file?

    ファイルの一行を変更する/ファイルのある行を削除する/ファイルの中程で一行挿入する/ファイルの先頭に追加するには?

  • How do I count the number of lines in a file?

    あるファイルの行数を数えるには?

  • How do I delete the last N lines from a file?

    ファイルの最後の N 行を削除するには?

  • How can I use Perl's -i option from within a program?

    プログラム内から Perl の -i オプションを使うには?

  • How can I copy a file?

    ファイルをコピーするには?

  • How do I make a temporary file name?

    一時ファイルの名前を作り出すには?

  • How can I manipulate fixed-record-length files?

    固定長レコードのファイルを操作するには?

  • How can I make a filehandle local to a subroutine? How do I pass filehandles between subroutines? How do I make an array of filehandles?

    ファイルハンドルをサブルーチンに局所化するには? サブルーチンにファイルハンドルを渡すには? ファイルハンドルの配列を作るには?

  • How can I use a filehandle indirectly?

    ファイルハンドルを間接的に扱うには?

  • How can I set up a footer format to be used with write()?

    write()と一緒に使うフッターのフォーマットのセットアップをする方法は?

  • How can I write() into a string?

    文字列に対して write() するには?

  • How can I open a filehandle to a string?

    ファイルハンドルを文字列としてオープンするには?

  • How can I output my numbers with commas added?

    出力する数字にカンマを付加するには?

  • How can I translate tildes (~) in a filename?

    ファイル名の中にあるチルダ (~) を変換するには?

  • How come when I open a file read-write it wipes it out?

    ファイルを読み書きモードでオープンしたときに内容をクリアしてしまうのはなぜ?

  • Why do I sometimes get an "Argument list too long" when I use <*>?

    なぜ <*> を使ったときに "Argument list too long" (引数リストが長すぎる)となることがあるの?

  • Is there a leak/bug in glob()?

    glob()に leak/bug はあるの?

  • How can I open a file with a leading ">" or trailing blanks?

    名前の先頭に">"があったり末尾に空白があるようなファイルをオープンするには?

  • How can I reliably rename a file?

    信頼性のあるファイルのリネームをするには?

  • How can I lock a file?

    ファイルをロックするには?

  • Why can't I just open(FH, ">file.lock")?

    なぜ単に open(FH, ">file.lock")とできないの?

  • I still don't get locking. I just want to increment the number in the file. How can I do this?

    まだロックができません。ただ単にファイルにある数値をインクリメントしたいだけなんだけど。どうすればいいの?

  • All I want to do is append a small amount of text to the end of a file. Do I still have to use locking?

    ファイルの末尾にちょっとしたテキストを追加したいだけなんです。それでもロックが必要なの?

  • How do I randomly update a binary file?

    バイナリファイルをランダムに更新するには?

  • How do I get a file's timestamp in perl?

    perl でファイルのタイムスタンプを取得するには?

  • How do I set a file's timestamp in perl?

    perl でファイルのタイムスタンプを設定するには?

  • How do I print to more than one file at once?

    複数のファイルを一度に表示するには?

  • How can I read in an entire file all at once?

    ファイル全体を一度に読みこむには?

  • How can I read in a file by paragraphs?

    ファイルをパラグラフ毎に読み込むには?

  • How can I read a single character from a file? From the keyboard?

    ファイルから 1 文字だけ読み出すには? キーボードからは?

  • How can I tell whether there's a character waiting on a filehandle?

    あるファイルハンドルが読み込み待ちの文字を待っているかどうかを知るには?

  • How do I do a tail -f in perl?

    perlで tail -f をするには?

  • How do I dup() a filehandle in Perl?

    Perl でファイルハンドルの dup() をするには?

  • How do I close a file descriptor by number?

    数値によるファイル記述子をクローズするには?

  • Why can't I use "C:\temp\foo" in DOS paths? Why doesn't `C:\temp\foo.exe` work?

    なぜ DOS のパスで "C:\temp\foo" が使えないの? なぜ `C:\temp\foo.exe` はうまくいかないの?

  • Why doesn't glob("*.*") get all the files?

    なぜ glob("*.*") で全てのファイルを得られないの?

  • Why does Perl let me delete read-only files? Why does -i clobber protected files? Isn't this a bug in Perl?

    なぜ Perl は読みとり専用ファイルを削除してしまうの? なぜ-i clobberはファイルをプロテクトするの? これは Perl のバグじゃないの?

  • How do I select a random line from a file?

    あるファイルからランダムに行を選択するには?

  • Why do I get weird spaces when I print an array of lines?

    行の配列を出力したときになぜ余計なスペースがつくの?

  • How do I traverse a directory tree?

    ディレクトリツリーを辿るには?

  • How do I delete a directory tree?

    ディレクトリツリーを削除するには?

  • How do I copy an entire directory?

    ディレクトリ全体をコピーするには?

perlfaq6: Regular Expressions

(perlfaq6: 正規表現)

This section is surprisingly small because the rest of the FAQ is littered with answers involving regular expressions. For example, decoding a URL and checking whether something is a number are handled with regular expressions, but those answers are found elsewhere in this document (in perlfaq9: "How do I decode or create those %-encodings on the web" and perlfaq4: "How do I determine whether a scalar is a number/whole/integer/float", to be precise).

この章は驚くほど小さくなっています。 なぜならFAQの残りの部分は 正規表現を伴った回答と一緒にあちこちに散在しているからです。 たとえばURLをデコードするとかあるものが数値かどうか確認することは 正規表現を使って処理されますが、この回答はこの資料のあらゆる所で 見つけることができます(正確には perlfaq9: "How do I decode or create those %-encodings on the web" と perlfaq4: "How do I determine whether a scalar is a number/whole/integer/float")。

  • How can I hope to use regular expressions without creating illegible and unmaintainable code?

    判読し難い、保守できないようなものにすることなく正規表現を使うには?

  • I'm having trouble matching over more than one line. What's wrong?

    二行以上に対するマッチングでトラブルがありました。何が悪いのでしょう?

  • How can I pull out lines between two patterns that are themselves on different lines?

    異なる行にある二つのパターンに挟まれている行を取り出すのはどうやればできますか?

  • How do I match XML, HTML, or other nasty, ugly things with a regex?

    XML, HTML あるいはその他の扱いにくくて不細工なものを正規表現でマッチングさせるには?

  • I put a regular expression into $/ but it didn't work. What's wrong?

    $/ に正規表現を入れたけど動きません。何が悪いの?

  • How do I substitute case-insensitively on the LHS while preserving case on the RHS?

    演算子の左辺では大小文字を無視して、演算子の右辺では元の大小文字を保存しておくような置換をするには?

  • How can I make \w match national character sets?

    \w がローカルな文字セットにマッチするようにするには?

  • How can I match a locale-smart version of /[a-zA-Z]/?

    /[a-zA-Z]/の locale-smart なバージョンでマッチさせるには?

  • How can I quote a variable to use in a regex?

    正規表現の中で使う変数をクォートするには?

  • What is /o really for?

    /o は実際なんのためのものなのですか?

  • How do I use a regular expression to strip C-style comments from a file?

    ファイルから、C 形式のコメントを剥ぎ取る(strip)するにはどのように正規表現を使えば良いのでしょうか?

  • Can I use Perl regular expressions to match balanced text?

    Perl の正規表現をバランスされたテキストのマッチングに使えますか?

  • What does it mean that regexes are greedy? How can I get around it?

    正規表現が貪欲(greedy)であるとはどういうことですか?

  • How do I process each word on each line?

    各行の単語単位に処理をするにはどうすれば良いですか?

  • How can I print out a word-frequency or line-frequency summary?

    語の出現頻度や行の出現頻度のまとめを出力するには?

  • How can I do approximate matching?

    曖昧なマッチング (approximate matching) はどうやればできますか?

  • How do I efficiently match many regular expressions at once?

    たくさんの正規表現を一度に効率良くマッチングするには?

  • Why don't word-boundary searches with \b work for me?

    なぜ \b を使った単語境界の検索がうまく行かないのでしょうか?

  • Why does using $&, $`, or $' slow my program down?

    なぜ $&, $`, $' を使うとプログラムが遅くなるの?

  • What good is \G in a regular expression?

    正規表現の中で \G を使うと何が良いのですか?

  • Are Perl regexes DFAs or NFAs? Are they POSIX compliant?

    Perl の正規表現ルーチンは DFA ですか NFA ですか? また、それは POSIX に従ってますか?

  • What's wrong with using grep in a void context?

    無効コンテキストで grep を使うことのどこが間違っているのでしょうか?

  • How can I match strings with multibyte characters?

    マルチバイト文字を含む文字列をマッチングさせるには?

  • How do I match a regular expression that's in a variable?

    変数に入っている正規表現でマッチングを行うには?

perlfaq7: General Perl Language Issues

(perlfaq7: Perl 言語一般に関することがら)

General Perl language issues that don't clearly fit into any of the other sections.

他のセクションにはきっちりとあてはまらないような Perl 言語に関する一般的な事柄。

  • Can I get a BNF/yacc/RE for the Perl language?

    Perl のための BNF/yacc/RE は入手できますか?

  • What are all these $@%&* punctuation signs, and how do I know when to use them?

    $@%&* のマークはなんですか? これらをいつ使えばいいのかを知るにはどうすればいいですか?

  • Do I always/never have to quote my strings or use semicolons and commas?

    文字列では常にクォートする/決してクォートしない必要があるのでしょうか? また、セミコロンやカンマについては?

  • How do I skip some return values?

    戻り値の一部をスキップするには?

  • How do I temporarily block warnings?

    一時的に警告をブロックするには?

  • What's an extension?

    エクステンションてなんですか?

  • Why do Perl operators have different precedence than C operators?

    なぜ Perl の演算子は C の演算子とは異なった優先順位を持っているのでしょうか?

  • How do I declare/create a structure?

    構造体を宣言したり生成するには?

  • How do I create a module?

    モジュールを作成するには?

  • How do I adopt or take over a module already on CPAN?

    すでに CPAN にあるモジュールを引き継ぐには?

  • How do I create a class?

    クラスを作るには?

  • How can I tell if a variable is tainted?

    変数が汚染されているかどうかを確かめるには?

  • What's a closure?

    クロージャ(closure)ってなんですか?

  • What is variable suicide and how can I prevent it?

    変数の自殺(variable suicide)って何で、それをどうすれば防げますか?

  • How can I pass/return a {Function, FileHandle, Array, Hash, Method, Regex}?

    {関数, ファイルハンドル, 配列, ハッシュ, メソッド, 正規表現} を渡したり返したりするには?

  • How do I create a static variable?

    静的変数を作るには?

  • What's the difference between dynamic and lexical (static) scoping? Between local() and my()?

    動的スコープとレキシカル(または静的)スコープとの間の違いは? local() と my() との違いは?

  • How can I access a dynamic variable while a similarly named lexical is in scope?

    どうやれば同じ名前のレキシカル変数がスコープにあるときに動的変数にアクセスできますか?

  • What's the difference between deep and shallow binding?

    深い束縛(deep binding)と浅い束縛(shallow binding)との間の違いとは?

  • Why doesn't "my($foo) = <FILE>;" work right?

    なぜ "my($foo) = <FILE>;" が正しく動作しないのでしょうか?

  • How do I redefine a builtin function, operator, or method?

    組み込みの関数や演算子、メソッドを再定義するには?

  • What's the difference between calling a function as &foo and foo()?

    関数呼び出しを &foo で行ったときと foo() で行ったときとの違いはなんですか?

  • How do I create a switch or case statement?

    switch 文や case 文を作るには?

  • How can I catch accesses to undefined variables, functions, or methods?

    どうすれば未定義な変数, 関数, メソッドに対するアクセスを捕捉できますか?

  • Why can't a method included in this same file be found?

    なぜ同じファイルにあるメソッドが見つけられないのでしょうか?

  • How can I find out my current or calling package?

    カレントのパッケージや呼び出しパッケージはどうすればわかりますか?

  • How can I comment out a large block of Perl code?

    Perl プログラムの大きなブロックをコメントアウトするには?

  • How do I clear a package?

    パッケージをクリアするには?

  • How can I use a variable as a variable name?

    変数を変数名として使うには?

  • What does "bad interpreter" mean?

    "bad interpreter" とはどういう意味ですか?

perlfaq8: System Interaction

(perlfaq8: システムとの相互作用)

This section of the Perl FAQ covers questions involving operating system interaction. Topics include interprocess communication (IPC), control over the user-interface (keyboard, screen and pointing devices), and most anything else not related to data manipulation. Read the FAQs and documentation specific to the port of perl to your operating system (eg, perlvms, perlplan9, ...). These should contain more detailed information on the vagaries of your perl.

FAQ のこのセクションでは、オペレーティングシステムとの対話に関する質問を 扱っています。 これにはプロセス間(IPC)、ユーザーインターフェース (キーボード、スクリーン、ポインティングデバイス)の制御、 その他データ操作に関連しないほとんどの事柄を含みます。 あなたの使っているオペレーティングシステム向けの移植について特有のことは、 それに関する FAQ とドキュメント(perlvms, perlplan9 など)を 読んでください。 そこには、あなたの使う perl についてのより詳しい情報があります。

  • How do I find out which operating system I'm running under?

    実行しているオペレーティングシステムを見分けるには?

  • How come exec() doesn't return?

    なぜ exec() は戻ってこないのでしょう?

  • How do I do fancy stuff with the keyboard/screen/mouse?

    キーボード/画面/マウスの凝った機能を使うには?

  • How do I print something out in color?

    色付きで何かを出力するには?

  • How do I read just one key without waiting for a return key?

    リターンキーを待たずにキーのデータを一つ読み取るには?

  • How do I check whether input is ready on the keyboard?

    キーの入力待ちがあるかどうかチェックするには?

  • How do I clear the screen?

    画面をクリアするには?

  • How do I get the screen size?

    画面サイズを得るには?

  • How do I ask the user for a password?

    ユーザーにパスワードを尋ねるには?

  • How do I read and write the serial port?

    シリアルポートの読み書きを行うには?

  • How do I decode encrypted password files?

    暗号化されたパスワードファイルを復号化するには?

  • How do I start a process in the background?

    バックグラウンドでプロセスを起動するには?

  • How do I trap control characters/signals?

    制御文字やシグナルをトラップするには?

  • How do I modify the shadow password file on a Unix system?

    UNIX システムのシャドウパスワードファイルを変更するには?

  • How do I set the time and date?

    日付や時刻を設定するには?

  • How can I sleep() or alarm() for under a second?

    一秒未満の時間に対する sleep() や alarm() をするには?

  • How can I measure time under a second?

    1 秒未満の時間を計るには?

  • How can I do an atexit() or setjmp()/longjmp()? (Exception handling)

    atexit() や setjmp()/longjmp() をするには? (例外処理)

  • Why doesn't my sockets program work under System V (Solaris)? What does the error message "Protocol not supported" mean?

    なぜ私のソケットプログラムはSystem V (Solaris) ではうまく動かないの? "Protocol not supported"というエラーメッセージの意味するところは?

  • How can I call my system's unique C functions from Perl?

    Perl から私のシステムに固有の C 関数を呼び出すには?

  • Where do I get the include files to do ioctl() or syscall()?

    ioctl() や syscall() で使うための include ファイルはどこで入手できますか?

  • Why do setuid perl scripts complain about kernel problems?

    なぜ setuid された perl スクリプトはカーネルの問題について文句を言うのでしょうか?

  • How can I open a pipe both to and from a command?

    あるコマンドに対する双方向のパイプをオープンするには?

  • Why can't I get the output of a command with system()?

    なぜ system() を使ったコマンドの出力を得ることができないのでしょうか?

  • How can I capture STDERR from an external command?

    外部コマンドの STDERR を捕捉するには?

  • Why doesn't open() return an error when a pipe open fails?

    なぜ open() は パイプのオープンに失敗したときにエラーを返さないのでしょうか?

  • What's wrong with using backticks in a void context?

    無効コンテキストで逆クォートを使うことのなにが悪いのでしょうか?

  • How can I call backticks without shell processing?

    シェルの処理をせずに逆クォートを呼び出すには?

  • Why can't my script read from STDIN after I gave it EOF (^D on Unix, ^Z on MS-DOS)?

    なぜ EOF(UNIX での^D、MS-DOS での^Z)を受け取った後で STDIN から読み込むことができないの?

  • How can I convert my shell script to perl?

    私のシェルスクリプトを perl に変換するには?

  • Can I use perl to run a telnet or ftp session?

    telnet や ftp のセッションを実行するために perl を使うことができますか?

  • How can I write expect in Perl?

     Perl で expect を書くには?
  • Is there a way to hide perl's command line from programs such as "ps"?

    “ps”のようなプログラムから、perl のコマンドラインを隠す方法はありますか?

  • I {changed directory, modified my environment} in a perl script. How come the change disappeared when I exited the script? How do I get my changes to be visible?

    perl スクリプトの中で、ディレクトリを変更したり環境変数を変更しました。なぜ、スクリプトを終了したときこれらの変更は無効になってしまうの? 変更が反映されるようにするには?

  • How do I close a process's filehandle without waiting for it to complete?

    プロセスの完了を待つことなしにそのファイルハンドルをクローズするには?

  • How do I fork a daemon process?

    デーモンプロセスを fork() するには?

  • How do I find out if I'm running interactively or not?

    自分が対話的に実行されているかどうかを知るには?

  • How do I timeout a slow event?

    遅いイベントをタイムアウトするには?

  • How do I set CPU limits?

    CPU のリミットを設定するには?

  • How do I avoid zombies on a Unix system?

    UNIX システムでゾンビを回避するには?

  • How do I use an SQL database?

    SQL データベースを使うには?

  • How do I make a system() exit on control-C?

    コントロール-C で system() が exit するようにするには?

  • How do I open a file without blocking?

    ブロックせずにファイルをオープンするには?

  • How do I tell the difference between errors from the shell and perl?

    シェルからと perl からのエラーを見分けるには?

  • How do I install a module from CPAN?

    モジュールを CPAN からインストールするには?

  • What's the difference between require and use?

    require と use の間の違いとは?

  • How do I keep my own module/library directory?

    自分自身のモジュール/ライブラリディレクトリを持つには?

  • How do I add the directory my program lives in to the module/library search path?

    私のプログラムの置いてある場所をモジュール/ライブラリの検索パスに追加するには?

  • How do I add a directory to my include path (@INC) at runtime?

    実行時にインクルードパス (@INC) にディレクトリを追加するには?

  • What is socket.ph and where do I get it?

    socket.ph とは一体何で、それはどこで入手できますか?

perlfaq9: Networking

(perlfaq9: ネットワーク)

Networking, the internet, and a few on the web.

ネットワーク、インターネット、web 関連。

  • What is the correct form of response from a CGI script?

    CGI スクリプトからの返答の正しい形は?

  • My CGI script runs from the command line but not the browser. (500 Server Error)

    (私の CGI スクリプトはコマンドラインでは動くのだけど、ブラウザ上では動きません (500 Server Error になります))

  • How can I get better error messages from a CGI program?

    CGI プログラムから、もっとまともなエラーメッセージを得るには?

  • How do I remove HTML from a string?

    ある文字列から HTML を取り除くには?

  • How do I extract URLs?

    URL の展開を行うには?

  • How do I download a file from the user's machine? How do I open a file on another machine?

    ユーザーのマシンからファイルをダウンロードするには? 別のマシンにあるファイルをオープンするには?

  • How do I make an HTML pop-up menu with Perl?

    Perl で HTML のポップアップメニューを作るには?

  • How do I fetch an HTML file?

    HTML ファイルをフェッチするには?

  • How do I automate an HTML form submission?

    HTML フォームの処理を自動化するには?

  • How do I decode or create those %-encodings on the web?

    web上で %-encodings をデコードしたり生成したりするには?

  • How do I redirect to another page?

    別のページにリダイレクトするには?

  • How do I put a password on my web pages?

    私の web ぺージでパスワードを入力するには?

  • How do I edit my .htpasswd and .htgroup files with Perl?

    Perl を使って .htpasswd や .htgroup といったファイルを編集するには?

  • How do I make sure users can't enter values into a form that cause my CGI script to do bad things?

    私の CGI スクリプトに悪影響をもたらすようなものを、ユーザーがフォームに入力できないようにするには?

  • How do I parse a mail header?

    メールのヘッダーを解析するには?

  • How do I decode a CGI form?

    CGI フォームをデコードするには?

  • How do I check a valid mail address?

    メールアドレスが正しいかチェックするには?

  • How do I decode a MIME/BASE64 string?

    MIME/BASE64 文字列のデコードを行うには?

  • How do I return the user's mail address?

    ユーザーのメールアドレスを返すには?

  • How do I send mail?

    メールを送るには?

  • How do I use MIME to make an attachment to a mail message?

    メールメッセージに添付するためにどうやって MIME を使えばいいですか?

  • How do I read mail?

    メールを読み出すには?

  • How do I find out my hostname, domainname, or IP address?

    私のホスト名/ドメイン名/IP アドレスを見つけるには?

  • How do I fetch a news article or the active newsgroups?

    ニュースの記事やアクティブなニュースグループを取得するには?

  • How do I fetch/put an FTP file?

    FTP ファイルをダウンロード/アップロードするには?

  • How can I do RPC in Perl?

    Perl で RPC を行うには?