=encoding euc-jp =head1 NAME =begin original perlfunc - Perl builtin functions =end original perlfunc - Perl 組み込み関数 =head1 DESCRIPTION =begin original The functions in this section can serve as terms in an expression. They fall into two major categories: list operators and named unary operators. These differ in their precedence relationship with a following comma. (See the precedence table in L.) List operators take more than one argument, while unary operators can never take more than one argument. Thus, a comma terminates the argument of a unary operator, but merely separates the arguments of a list operator. A unary operator generally provides a scalar context to its argument, while a list operator may provide either scalar or list contexts for its arguments. If it does both, the scalar arguments will be first, and the list argument will follow. (Note that there can ever be only one such list argument.) For instance, splice() has three scalar arguments followed by a list, whereas gethostbyname() has four scalar arguments. =end original この節の関数は、式の中で項として使うことができます。 これらは、大きく 2 つに分けられます: リスト演算子と名前付き単項演算子です。 これらの違いは、その後に出て来るコンマとの優先順位の関係にあります。  (L の優先順位の表を参照してください。) リスト演算子は 2 個以上の引数をとるのに対して、 単項演算子が複数の引数をとることはありません。 つまり、コンマは単項演算子の引数の終わりとなりますが、 リスト演算子の場合には、引数の区切りでしかありません。 単項演算子は一般に、 引数に対してスカラコンテキストを与えるのに対して、 スカラ演算子の場合には、引数に対してスカラコンテキストを与える場合も、 リストコンテキストを与える場合もあります。 1 つのリスト演算子が 両方のコンテキストを与える場合には、スカラ引数がいくつか並び、 最後にリスト引数が 1 つ続きます。 (リスト引数は 1 つだけです。) たとえば、splice() は 3 つのスカラ引数に 1 つのリスト引数が続きます。 一方 gethostbyname() は 4 つのスカラ引数を持ちます。 =begin original In the syntax descriptions that follow, list operators that expect a list (and provide list context for the elements of the list) are shown with LIST as an argument. Such a list may consist of any combination of scalar arguments or list values; the list values will be included in the list as if each individual element were interpolated at that point in the list, forming a longer single-dimensional list value. Elements of the LIST should be separated by commas. =end original 後に載せる構文記述では、リストをとり (そのリストの要素にリストコンテキストを与える) リスト演算子は、引数として LIST をとるように書いています。 そのようなリストには、任意のスカラ引数の組み合わせやリスト値を 含めることができ、リスト値はリストの中に、 個々の要素が展開されたように埋め込まれます。 1 次元の長いリスト値が形成されることになります。 LIST の要素は、コンマで区切られている必要があります。 =begin original Any function in the list below may be used either with or without parentheses around its arguments. (The syntax descriptions omit the parentheses.) If you use the parentheses, the simple (but occasionally surprising) rule is this: It I like a function, therefore it I a function, and precedence doesn't matter. Otherwise it's a list operator or unary operator, and precedence does matter. And whitespace between the function and left parenthesis doesn't count--so you need to be careful sometimes: =end original 以下のリストの関数はすべて、引数の前後の括弧は省略可能と なっています。 (構文記述では省略しています。) 括弧を使うときには、 単純な (しかし、ときには驚く結果となる) 規則が適用できます: I<関数に見える>ならば、I<それは関数>で、優先順位は関係ありません。 そう見えなければ、それはリスト演算子か単項演算子で、優先順位が 関係します。 また、関数と開き括弧の間の空白は関係ありませんので、 ときに気を付けなければなりません: print 1+2+4; # Prints 7. print(1+2) + 4; # Prints 3. print (1+2)+4; # Also prints 3! print +(1+2)+4; # Prints 7. print ((1+2)+4); # Prints 7. =begin original If you run Perl with the B<-w> switch it can warn you about this. For example, the third line above produces: print (...) interpreted as function at - line 1. Useless use of integer addition in void context at - line 1. =end original Perl に B<-w> スイッチを付けて実行すれば、こういったものには 警告を出してくれます。 たとえば、上記の 3 つめは、以下のような警告が出ます: print (...) interpreted as function at - line 1. Useless use of integer addition in void context at - line 1. =begin original A few functions take no arguments at all, and therefore work as neither unary nor list operators. These include such functions as C