<?xml version='1.0' encoding='utf-8'?>
<pod xmlns="http://axkit.org/ns/2000/pod2xml">
<head>
	<title>NAME
<index>tie</index></title>
</head>
<sect1>
<title>NAME
<index>tie</index></title>
<para>
perltie - how to hide an object class in a simple variable
</para>
<para>
perltie - オブジェクトクラスを単純な変数に隠す方法
</para>
</sect1>
<sect1>
<title>SYNOPSIS</title>
<verbatim><![CDATA[
tie VARIABLE, CLASSNAME, LIST
]]></verbatim>
<verbatim><![CDATA[
$object = tied VARIABLE
]]></verbatim>
<verbatim><![CDATA[
untie VARIABLE
]]></verbatim>
</sect1>
<sect1>
<title>DESCRIPTION</title>
<para>
Prior to release 5.0 of Perl, a programmer could use dbmopen()
to connect an on-disk database in the standard Unix dbm(3x)
format magically to a %HASH in their program.  However, their Perl was either
built with one particular dbm library or another, but not both, and
you couldn't extend this mechanism to other packages or types of variables.
</para>
<para>
5.0 より前の Perl では、プログラマは dbmopen() を使ってディスクにある
標準 UNIX dbm(3x) フォーマットのデータベースをプログラム中の %HASH と
結び付けることができました。
しかしながら、Perl は特定の dbm ライブラリか別のものを使って
ビルドすることができたものの、両方一度にはできませんでした。
そして、この仕組みを他のパッケージや変数の型に拡張することは
できなかったのです。
</para>
<para>
Now you can.
</para>
<para>
今はできます。
</para>
<para>
The tie() function binds a variable to a class (package) that will provide
the implementation for access methods for that variable.  Once this magic
has been performed, accessing a tied variable automatically triggers
method calls in the proper class.  The complexity of the class is
hidden behind magic methods calls.  The method names are in ALL CAPS,
which is a convention that Perl uses to indicate that they're called
implicitly rather than explicitly--just like the BEGIN() and END()
functions.
</para>
<para>
tie() 関数は変数と、その変数に対するアクセスメソッドの実装を提供する
クラス(パッケージ)とを結び付けます。
この魔法が一度働けば、tie された変数は自動的に適切なクラスにある
メソッド呼び出しを実行します。
クラスのすべての複雑性はメソッド呼び出しに隠されます。
それらのメソッドの名前は、BEGIN() や END() と同様に(そのメソッドを) Perl が
こっそりと呼び出すことを示すための規約に従って全て大文字です。
</para>
<para>
In the tie() call, <code>VARIABLE</code> is the name of the variable to be
enchanted.  <code>CLASSNAME</code> is the name of a class implementing objects of
the correct type.  Any additional arguments in the <code>LIST</code> are passed to
the appropriate constructor method for that class--meaning TIESCALAR(),
TIEARRAY(), TIEHASH(), or TIEHANDLE().  (Typically these are arguments
such as might be passed to the dbminit() function of C.) The object
returned by the &quot;new&quot; method is also returned by the tie() function,
which would be useful if you wanted to access other methods in
<code>CLASSNAME</code>. (You don't actually have to return a reference to a right
&quot;type&quot; (e.g., HASH or <code>CLASSNAME</code>) so long as it's a properly blessed
object.)  You can also retrieve a reference to the underlying object
using the tied() function.
</para>
<para>
tie() コールの中で、<code>VARIABLE</code> は魔法を掛けられる変数の名前です。
<code>CLASSNAME</code> は正しい型のオブジェクトを実装するクラスの名前です。
<code>LIST</code> にあるその他の引数はクラスの適切なコンストラクタメソッド
TIESCALAR()、TIEARRAY()、TIEHASH()、TIEHANDLE() のいずれかに
渡されます(典型的にはこれらの引数は C の dbminit() 関数に渡すのと
同じものです)。
&quot;new&quot; メソッドから返されたオブジェクトは同様に関数 tie() からも
返されます。
これはあなたが <code>CLASSNAME</code> の中の別のメソッドでアクセスしたいというときに
便利でしょう(あなたは実際には正しい「型」(HASH か <code>CLASSNAME</code>) の
参照を、それが適切な bless されたオブジェクトであるということから
返す必要はありません)。
また、関数 tied() を使って、基礎となるオブジェクトへのリファレンスを
取得することができます。
</para>
<para>
Unlike dbmopen(), the tie() function will not <code>use</code> or <code>require</code> a module
for you--you need to do that explicitly yourself.
</para>
<para>
dbmopen() とは異なり、tie() はモジュールを <code>use</code> したり <code>require</code> したり
することはありません。
あなたが、自分自身でそれを明示的に行わなければなりません。
</para>
<sect2>
<title>Tying Scalars
<index>scalar, tying</index></title>
<para>
(スカラを tie する)
</para>
<para>
A class implementing a tied scalar should define the following methods:
TIESCALAR, FETCH, STORE, and possibly UNTIE and/or DESTROY.
</para>
<para>
tie されたスカラを実装するクラスは、TIESCALAR, FETCH, STORE, 
そして可能であれば UNTIE や DESTROY といったメソッドを定義しておくべきです。
</para>
<para>
Let's look at each in turn, using as an example a tie class for
scalars that allows the user to do something like:
</para>
<para>
以下のような操作を、ユーザーに許しているスカラに対してクラスを
tie する例を使って順に見て行きましょう。
</para>
<verbatim><![CDATA[
tie $his_speed, 'Nice', getppid();
tie $my_speed,  'Nice', $$;
]]></verbatim>
<para>
And now whenever either of those variables is accessed, its current
system priority is retrieved and returned.  If those variables are set,
then the process's priority is changed!
</para>
<para>
こうした後ではこれらの変数のいずれかがアクセスされたときには、カレントの
システム優先順位が取得されたり返されたりします。
もし変数に代入が行われれば、プロセスの優先順位は変更されます!
</para>
<para>
We'll use Jarkko Hietaniemi &lt;<filename>jhi@iki.fi</filename>&gt;'s BSD::Resource class (not
included) to access the PRIO_PROCESS, PRIO_MIN, and PRIO_MAX constants
from your system, as well as the getpriority() and setpriority() system
calls.  Here's the preamble of the class.
</para>
<para>
システムの PRIO_PROCESS, PRIO_MIN, PRIO_MAX といった定数に
アクセスするために Jarkko Hietaniemi &lt;<filename>jhi@iki.fi</filename>&gt; の
BSD::Resource クラスを使います。
以下はこのクラスの前置きです。
</para>
<verbatim><![CDATA[
package Nice;
use Carp;
use BSD::Resource;
use strict;
$Nice::DEBUG = 0 unless defined $Nice::DEBUG;
]]></verbatim>
<list>
<item><itemtext>TIESCALAR classname, LIST
<index>TIESCALAR</index></itemtext>
<para>
This is the constructor for the class.  That means it is
expected to return a blessed reference to a new scalar
(probably anonymous) that it's creating.  For example:
</para>
<para>
これはクラスのためのコンストラクタです。
その役割は作成された新たな(おそらくは無名の)スカラへの bless された
参照を返すことです。
たとえば、
</para>
<verbatim><![CDATA[
sub TIESCALAR {
    my $class = shift;
    my $pid = shift || $$; # 0 means me
]]></verbatim>
<verbatim><![CDATA[
if ($pid !~ /^\d+$/) {
    carp "Nice::Tie::Scalar got non-numeric pid $pid" if $^W;
    return undef;
}
]]></verbatim>
<verbatim><![CDATA[
unless (kill 0, $pid) { # EPERM or ERSCH, no doubt
    carp "Nice::Tie::Scalar got bad pid $pid: $!" if $^W;
    return undef;
}
]]></verbatim>
<verbatim><![CDATA[
return bless \$pid, $class;
    }
]]></verbatim>
<para>
This tie class has chosen to return an error rather than raising an
exception if its constructor should fail.  While this is how dbmopen() works,
other classes may well not wish to be so forgiving.  It checks the global
variable <code>$^W</code> to see whether to emit a bit of noise anyway.
</para>
<para>
このtie クラスでは、コンストラクタが失敗したときに例外を起こすのではなく
エラーを返すことを選択しました。
dbmopen() が動作している間に、他のクラスは例外が起きることを
好まないかもしれないからです。
グローバル変数 <code>$^W</code> でエラーメッセージを出すかどうかを検査しています。
</para>
</item>
<item><itemtext>FETCH this
<index>FETCH</index></itemtext>
<para>
This method will be triggered every time the tied variable is accessed
(read).  It takes no arguments beyond its self reference, which is the
object representing the scalar we're dealing with.  Because in this case
we're using just a SCALAR ref for the tied scalar object, a simple $$self
allows the method to get at the real value stored there.  In our example
below, that real value is the process ID to which we've tied our variable.
</para>
<para>
このメソッドは tie された変数がアクセス(読み出し)される度に起動されます。
これは自分のリファレンス、つまり私たちが扱おうとしている
スカラを表現するオブジェクトの他に引数は取りません。
この場合、単に SCALAR の参照をtieされたスカラオブジェクトとして
使うので、単純な $$self がそこに格納されている実際の値を取得する
メソッドとなります。
以下に示した例では、実際の値は変数に tie されたプロセス ID です。
</para>
<verbatim><![CDATA[
sub FETCH {
    my $self = shift;
    confess "wrong type" unless ref $self;
    croak "usage error" if @_;
    my $nicety;
    local($!) = 0;
    $nicety = getpriority(PRIO_PROCESS, $$self);
    if ($!) { croak "getpriority failed: $!" }
    return $nicety;
}
]]></verbatim>
<para>
This time we've decided to blow up (raise an exception) if the renice
fails--there's no place for us to return an error otherwise, and it's
probably the right thing to do.
</para>
<para>
ここでは、renice に失敗した場合には例外を引き起こすようにしました。
エラーを返すための場所がなく、例外を引き起こすことがおそらく妥当です。
</para>
</item>
<item><itemtext>STORE this, value
<index>STORE</index></itemtext>
<para>
This method will be triggered every time the tied variable is set
(assigned).  Beyond its self reference, it also expects one (and only one)
argument--the new value the user is trying to assign. Don't worry about
returning a value from STORE -- the semantic of assignment returning the
assigned value is implemented with FETCH.
</para>
<para>
このメソッドは tie された変数に代入される度毎に起動されます。
自分の参照のほか、ただ一つの引数としてユーザーが代入しようとする
新しい値を取ります。
STORE から返される値は気にしないで下さい --
代入された値を返す代入の動作は FETCH で実装されています。
</para>
<verbatim><![CDATA[
sub STORE {
    my $self = shift;
    confess "wrong type" unless ref $self;
    my $new_nicety = shift;
    croak "usage error" if @_;
]]></verbatim>
<verbatim><![CDATA[
if ($new_nicety < PRIO_MIN) {
    carp sprintf
      "WARNING: priority %d less than minimum system priority %d",
          $new_nicety, PRIO_MIN if $^W;
    $new_nicety = PRIO_MIN;
}
]]></verbatim>
<verbatim><![CDATA[
if ($new_nicety > PRIO_MAX) {
    carp sprintf
      "WARNING: priority %d greater than maximum system priority %d",
          $new_nicety, PRIO_MAX if $^W;
    $new_nicety = PRIO_MAX;
}
]]></verbatim>
<verbatim><![CDATA[
unless (defined setpriority(PRIO_PROCESS, $$self, $new_nicety)) {
    confess "setpriority failed: $!";
}
    }
]]></verbatim>
</item>
<item><itemtext>UNTIE this
<index>UNTIE</index></itemtext>
<para>
This method will be triggered when the <code>untie</code> occurs. This can be useful
if the class needs to know when no further calls will be made. (Except DESTROY
of course.) See <link xref='The {tag:code>untie{#tag:code} Gotcha'}The <code>untie</code> Gotcha</link> below for more details.
</para>
<para>
このメソッドは、<code>untie</code> が発生すると起動されます。
これは、クラスが、もはや呼び出されなくなるのはいつかを知る必要がある場合に
便利です。
(もちろん DESTROY を除いてです。)
さらなる詳細については後述する <link xref='The {tag:code>untie{#tag:code} Gotcha'}The <code>untie</code> Gotcha</link> を参照してください。
</para>
</item>
<item><itemtext>DESTROY this
<index>DESTROY</index></itemtext>
<para>
This method will be triggered when the tied variable needs to be destructed.
As with other object classes, such a method is seldom necessary, because Perl
deallocates its moribund object's memory for you automatically--this isn't
C++, you know.  We'll use a DESTROY method here for debugging purposes only.
</para>
<para>
このメソッドは tie された変数を破棄する必要があるときに起動されます。
他のオブジェクトクラスと同じように、このようなメソッドは
ほとんど必要ありません。
それは、Perl は消滅しかかったオブジェクトのメモリを自動的に
解放するからです。
これは C++ ではないのです。
いいですね?。
私たちはここでは DESTROY メソッドをデバッグのためだけに使います。
</para>
<verbatim><![CDATA[
sub DESTROY {
    my $self = shift;
    confess "wrong type" unless ref $self;
    carp "[ Nice::DESTROY pid $$self ]" if $Nice::DEBUG;
}
]]></verbatim>
</item>
</list>
<para>
That's about all there is to it.  Actually, it's more than all there
is to it, because we've done a few nice things here for the sake
of completeness, robustness, and general aesthetics.  Simpler
TIESCALAR classes are certainly possible.
</para>
<para>
これがすべきことの全てです。
実際のところ、それよりも多くのことがあります。
ですから、私たちはここでちょっとした完全性、堅牢性、一般的な美しさと
いうものを込めました。
もっと簡単な TIESCALAR クラスを作ることも可能です。
</para>
</sect2>
<sect2>
<title>Tying Arrays
<index>array, tying</index></title>
<para>
(配列を tie する)
</para>
<para>
A class implementing a tied ordinary array should define the following
methods: TIEARRAY, FETCH, STORE, FETCHSIZE, STORESIZE and perhaps UNTIE and/or DESTROY.
</para>
<para>
tie された配列を実装するクラスは TIEARRAY, FETCH, STORE, FETCHSIZE, 
STORESIZE、そしておそらく UNTIE や DESTROY といったメソッドを
実装すべきでしょう。
</para>
<para>
FETCHSIZE and STORESIZE are used to provide <code>$#array</code> and
equivalent <code>scalar(@array)</code> access.
</para>
<para>
FETCHSIZE と STORESIZE は <code>$#array</code> と
<code>scalar(@array)</code> アクセスに等価なものを提供します。
</para>
<para>
The methods POP, PUSH, SHIFT, UNSHIFT, SPLICE, DELETE, and EXISTS are
required if the perl operator with the corresponding (but lowercase) name
is to operate on the tied array. The <strong>Tie::Array</strong> class can be used as a
base class to implement the first five of these in terms of the basic
methods above.  The default implementations of DELETE and EXISTS in
<strong>Tie::Array</strong> simply <code>croak</code>.
</para>
<para>
POP, PUSH, SHIFT, UNSHIFT, SPLICE, DELETE, EXIST といったメソッドは
同名の perl の演算子(ただし小文字)が tie された配列に対して
操作を行うときに必要となります。
<strong>Tie::Array</strong> クラスは、これらのうち、最初の 5 つの基本的なメソッドを
実装するための基底クラスとして使用できます。
<strong>Tie::Array</strong> での DELETE と EXISTS のデフォルトの実装は
単なる <code>croak</code> です。
</para>
<para>
In addition EXTEND will be called when perl would have pre-extended
allocation in a real array.
</para>
<para>
それに加え、EXTEND は perl が実際の配列中であらかじめ
拡張するようなときに呼び出されます。
</para>
<para>
For this discussion, we'll implement an array whose elements are a fixed
size at creation.  If you try to create an element larger than the fixed
size, you'll take an exception.  For example:
</para>
<para>
ここでの説明のため、要素数が生成時に固定されたサイズである配列を実装します。
固定サイズを越えた要素を作ろうとすると、例外が発生します。
例えば:
</para>
<verbatim><![CDATA[
use FixedElem_Array;
tie @array, 'FixedElem_Array', 3;
$array[0] = 'cat';  # ok.
$array[1] = 'dogs'; # exception, length('dogs') > 3.
]]></verbatim>
<para>
The preamble code for the class is as follows:
</para>
<para>
このクラスに対する 前置きコードは以下の通りです。
</para>
<verbatim><![CDATA[
package FixedElem_Array;
use Carp;
use strict;
]]></verbatim>
<list>
<item><itemtext>TIEARRAY classname, LIST
<index>TIEARRAY</index></itemtext>
<para>
This is the constructor for the class.  That means it is expected to
return a blessed reference through which the new array (probably an
anonymous ARRAY ref) will be accessed.
</para>
<para>
これはクラスのためのコンストラクタです。
その役割は作成された新たな(おそらくは無名の配列の参照)配列への
bless された参照を返すことです。
</para>
<para>
In our example, just to show you that you don't <emphasis>really</emphasis> have to return an
ARRAY reference, we'll choose a HASH reference to represent our object.
A HASH works out well as a generic record type: the <code>{ELEMSIZE}</code> field will
store the maximum element size allowed, and the <code>{ARRAY}</code> field will hold the
true ARRAY ref.  If someone outside the class tries to dereference the
object returned (doubtless thinking it an ARRAY ref), they'll blow up.
This just goes to show you that you should respect an object's privacy.
</para>
<para>
私たちの例では、あなたにあなたが <emphasis>実際には</emphasis> ARRAY のリファレンスを
返さなくてもよいということを示すためだけに、使用するオブジェクトを
表わす HASH の参照を選びました。
HASH は汎用的なレコード型と同じように働きます。
<code>{ELEMSIZE}</code> フィールドは許される最大の要素の数を格納し、
<code>{ARRAY}</code> フィールドは本物の ARRAY のリファレンスを保持します。
誰かがクラスの外側で返されたオブジェクトのデリファレンスを試みた場合
(それが ARRAY のリファレンスであると疑いなく考えて)、それは失敗します。
これはあなたがオブジェクトのプライバシーを尊重すべきであるという
ことなのです。
</para>
<verbatim><![CDATA[
sub TIEARRAY {
  my $class    = shift;
  my $elemsize = shift;
  if ( @_ || $elemsize =~ /\D/ ) {
    croak "usage: tie ARRAY, '" . __PACKAGE__ . "', elem_size";
  }
  return bless {
    ELEMSIZE => $elemsize,
    ARRAY    => [],
  }, $class;
}
]]></verbatim>
</item>
<item><itemtext>FETCH this, index
<index>FETCH</index></itemtext>
<para>
This method will be triggered every time an individual element the tied array
is accessed (read).  It takes one argument beyond its self reference: the
index whose value we're trying to fetch.
</para>
<para>
このメソッドは tie された配列の個々の要素がアクセス(読み出し)される毎に
起動されます。
これは自分の参照のほかに、一つの引数、フェッチしようとする値の
インデックスをとります。
</para>
<verbatim><![CDATA[
sub FETCH {
  my $self  = shift;
  my $index = shift;
  return $self->{ARRAY}->[$index];
}
]]></verbatim>
<para>
If a negative array index is used to read from an array, the index
will be translated to a positive one internally by calling FETCHSIZE
before being passed to FETCH.  You may disable this feature by
assigning a true value to the variable <code>$NEGATIVE_INDICES</code> in the
tied array class.
</para>
<para>
配列からの読み込みに負数の添え字が使われると、添え字は
FETCH に渡される前に FETCHSIZE を呼び出すことで正の数に変換されます。
tie された配列クラスの <code>$NEGATIVE_INDICES</code> に真の値を代入することで
この機能を無効にできます。
</para>
<para>
As you may have noticed, the name of the FETCH method (et al.) is the same
for all accesses, even though the constructors differ in names (TIESCALAR
vs TIEARRAY).  While in theory you could have the same class servicing
several tied types, in practice this becomes cumbersome, and it's easiest
to keep them at simply one tie type per class.
</para>
<para>
すでに気がついたかもしれませんが、FETCH メソッド(など)の名前は全ての
アクセスについて、たとえコンストラクタが別の名前であった
(TIESCALAR と TIEARRAY)としても同じ名前になっています。
理論的には、幾つかの tie されたクラスをサービスする同じクラスを
持つこともできるでしょうが、実際にはこれは厄介なものになり、
単にクラスあたり一つの状態にするのが最も簡単です。
</para>
</item>
<item><itemtext>STORE this, index, value
<index>STORE</index></itemtext>
<para>
This method will be triggered every time an element in the tied array is set
(written).  It takes two arguments beyond its self reference: the index at
which we're trying to store something and the value we're trying to put
there.
</para>
<para>
このメソッドは、tie された配列にある要素に対する書き込みがある度毎に
起動されます。
これは自分の参照のほかに、何かを格納しようとする場所の添え字と、
格納しようとしている値という二つの引数を取ります。
</para>
<para>
In our example, <code>undef</code> is really <code>$self-&gt;{ELEMSIZE}</code> number of
spaces so we have a little more work to do here:
</para>
<para>
この例では、<code>undef</code> は実際は <code>$self-&gt;{ELEMSIZE}</code> 個の空白なので、
ここでもう少し作業が必要です:
</para>
<verbatim><![CDATA[
sub STORE {
  my $self = shift;
  my( $index, $value ) = @_;
  if ( length $value > $self->{ELEMSIZE} ) {
    croak "length of $value is greater than $self->{ELEMSIZE}";
  }
  # fill in the blanks
  $self->EXTEND( $index ) if $index > $self->FETCHSIZE();
  # right justify to keep element size for smaller elements
  $self->{ARRAY}->[$index] = sprintf "%$self->{ELEMSIZE}s", $value;
}
]]></verbatim>
<para>
Negative indexes are treated the same as with FETCH.
</para>
<para>
インデックスの値が負数の場合、FETCH と同様に扱われます。
</para>
</item>
<item><itemtext>FETCHSIZE this
<index>FETCHSIZE</index></itemtext>
<para>
Returns the total number of items in the tied array associated with
object <emphasis>this</emphasis>. (Equivalent to <code>scalar(@array)</code>).  For example:
</para>
<para>
オブジェクト <emphasis>this</emphasis> と結び付けられた tie された配列の合計要素数を返します。
(<code>scalar(@array)</code> と等価です)。
例えば:
</para>
<verbatim><![CDATA[
sub FETCHSIZE {
  my $self = shift;
  return scalar @{$self->{ARRAY}};
}
]]></verbatim>
</item>
<item><itemtext>STORESIZE this, count
<index>STORESIZE</index></itemtext>
<para>
Sets the total number of items in the tied array associated with
object <emphasis>this</emphasis> to be <emphasis>count</emphasis>. If this makes the array larger then
class's mapping of <code>undef</code> should be returned for new positions.
If the array becomes smaller then entries beyond count should be
deleted.
</para>
<para>
オブジェクト <emphasis>this</emphasis> に結び付けられた tie された配列のアイテムの合計数を
<emphasis>count</emphasis> にセットします。
もし配列がより大きくなるなら、新しい位置ではクラスのマッピングは
<code>undef</code> を返すべきです。
もし配列がより小さくなるなら、count を超えたエントリは削除されるべきです。
</para>
<para>
In our example, 'undef' is really an element containing
<code>$self-&gt;{ELEMSIZE}</code> number of spaces.  Observe:
</para>
<para>
この例では、'undef' というのは実際には <code>$self-&gt;{ELEMSIZE}</code> 個の空白を
含む要素です。
これを見てください:
</para>
<verbatim><![CDATA[
sub STORESIZE {
  my $self  = shift;
  my $count = shift;
  if ( $count > $self->FETCHSIZE() ) {
    foreach ( $count - $self->FETCHSIZE() .. $count ) {
      $self->STORE( $_, '' );
    }
  } elsif ( $count < $self->FETCHSIZE() ) {
    foreach ( 0 .. $self->FETCHSIZE() - $count - 2 ) {
      $self->POP();
    }
  }
}
]]></verbatim>
</item>
<item><itemtext>EXTEND this, count
<index>EXTEND</index></itemtext>
<para>
Informative call that array is likely to grow to have <emphasis>count</emphasis> entries.
Can be used to optimize allocation. This method need do nothing.
</para>
<para>
配列が、<emphasis>count</emphasis> エントリに大きくなりそうだということを通知する
呼び出しです。
割り当ての最適化に使えます。
このメソッドで何かをしなければならないということはありません。
</para>
<para>
In our example, we want to make sure there are no blank (<code>undef</code>)
entries, so <code>EXTEND</code> will make use of <code>STORESIZE</code> to fill elements
as needed:
</para>
<para>
例では、空白 (<code>undef</code>) のエントリがないことを確実にしたいので、
<code>EXTEND</code> は必要に応じて要素を埋めるために <code>STORESIZE</code> を使います:
</para>
<verbatim><![CDATA[
sub EXTEND {   
  my $self  = shift;
  my $count = shift;
  $self->STORESIZE( $count );
}
]]></verbatim>
</item>
<item><itemtext>EXISTS this, key
<index>EXISTS</index></itemtext>
<para>
Verify that the element at index <emphasis>key</emphasis> exists in the tied array <emphasis>this</emphasis>.
</para>
<para>
tie された配列 <emphasis>this</emphasis> にインデックスが <emphasis>key</emphasis> である要素が存在するかを
検証します。
</para>
<para>
In our example, we will determine that if an element consists of
<code>$self-&gt;{ELEMSIZE}</code> spaces only, it does not exist:
</para>
<para>
この例では、要素が <code>$self-&gt;{ELEMSIZE}</code> 個の空白のみで構成されていれば、
これは存在しません:
</para>
<verbatim><![CDATA[
sub EXISTS {
  my $self  = shift;
  my $index = shift;
  return 0 if ! defined $self->{ARRAY}->[$index] ||
              $self->{ARRAY}->[$index] eq ' ' x $self->{ELEMSIZE};
  return 1;
}
]]></verbatim>
</item>
<item><itemtext>DELETE this, key
<index>DELETE</index></itemtext>
<para>
Delete the element at index <emphasis>key</emphasis> from the tied array <emphasis>this</emphasis>.
</para>
<para>
インデックス <emphasis>key</emphasis> の要素を tie された配列 <emphasis>this</emphasis> から削除します。
</para>
<para>
In our example, a deleted item is <code>$self-&gt;{ELEMSIZE}</code> spaces:
</para>
<para>
この例では、削除された要素は <code>$self-&gt;{ELEMSIZE}</code> 個の空白です:
</para>
<verbatim><![CDATA[
sub DELETE {
  my $self  = shift;
  my $index = shift;
  return $self->STORE( $index, '' );
}
]]></verbatim>
</item>
<item><itemtext>CLEAR this
<index>CLEAR</index></itemtext>
<para>
Clear (remove, delete, ...) all values from the tied array associated with
object <emphasis>this</emphasis>.  For example:
</para>
<para>
オブジェクト <emphasis>this</emphasis> に関連付けられた tie された配列から全ての値を
削除します。
例えば:
</para>
<verbatim><![CDATA[
sub CLEAR {
  my $self = shift;
  return $self->{ARRAY} = [];
}
]]></verbatim>
</item>
<item><itemtext>PUSH this, LIST 
<index>PUSH</index></itemtext>
<para>
Append elements of <emphasis>LIST</emphasis> to the array.  For example:
</para>
<para>
<emphasis>LIST</emphasis> の要素を配列に追加します。
例えば:
</para>
<verbatim><![CDATA[
sub PUSH {  
  my $self = shift;
  my @list = @_;
  my $last = $self->FETCHSIZE();
  $self->STORE( $last + $_, $list[$_] ) foreach 0 .. $#list;
  return $self->FETCHSIZE();
}
]]></verbatim>
</item>
<item><itemtext>POP this
<index>POP</index></itemtext>
<para>
Remove last element of the array and return it.  For example:
</para>
<para>
配列の最後の要素を取り除いてそれを返します。
例えば:
</para>
<verbatim><![CDATA[
sub POP {
  my $self = shift;
  return pop @{$self->{ARRAY}};
}
]]></verbatim>
</item>
<item><itemtext>SHIFT this
<index>SHIFT</index></itemtext>
<para>
Remove the first element of the array (shifting other elements down)
and return it.  For example:
</para>
<para>
配列の最初の要素を取り除いて(残りの要素はシフトします)、その要素を返します。
例えば:
</para>
<verbatim><![CDATA[
sub SHIFT {
  my $self = shift;
  return shift @{$self->{ARRAY}};
}
]]></verbatim>
</item>
<item><itemtext>UNSHIFT this, LIST 
<index>UNSHIFT</index></itemtext>
<para>
Insert LIST elements at the beginning of the array, moving existing elements
up to make room.  For example:
</para>
<para>
LIST 要素を配列の先頭に挿入し、すでにある要素は場所を空けるために
移動します。
例えば:
</para>
<verbatim><![CDATA[
sub UNSHIFT {
  my $self = shift;
  my @list = @_;
  my $size = scalar( @list );
  # make room for our list
  @{$self->{ARRAY}}[ $size .. $#{$self->{ARRAY}} + $size ]
   = @{$self->{ARRAY}};
  $self->STORE( $_, $list[$_] ) foreach 0 .. $#list;
}
]]></verbatim>
</item>
<item><itemtext>SPLICE this, offset, length, LIST
<index>SPLICE</index></itemtext>
<para>
Perform the equivalent of <code>splice</code> on the array.
</para>
<para>
配列に対する <code>splice</code> と等価に振る舞います。
</para>
<para>
<emphasis>offset</emphasis> is optional and defaults to zero, negative values count back 
from the end of the array.
</para>
<para>
<emphasis>offset</emphasis> はオプションでデフォルトは 0 です; 負数は配列の最後からの
位置を示します。
</para>
<para>
<emphasis>length</emphasis> is optional and defaults to rest of the array.
</para>
<para>
<emphasis>length</emphasis> はオプションで、デフォルトは配列の残りです。
</para>
<para>
<emphasis>LIST</emphasis> may be empty.
</para>
<para>
<emphasis>LIST</emphasis> は空かもしれません。
</para>
<para>
Returns a list of the original <emphasis>length</emphasis> elements at <emphasis>offset</emphasis>.
</para>
<para>
元の、<emphasis>offset</emphasis> の位置から <emphasis>length</emphasis> 要素分のリストを返します。
</para>
<para>
In our example, we'll use a little shortcut if there is a <emphasis>LIST</emphasis>:
</para>
<para>
この例では、<emphasis>LIST</emphasis> がある場合は少し近道をします:
</para>
<verbatim><![CDATA[
sub SPLICE {
  my $self   = shift;
  my $offset = shift || 0;
  my $length = shift || $self->FETCHSIZE() - $offset;
  my @list   = (); 
  if ( @_ ) {
    tie @list, __PACKAGE__, $self->{ELEMSIZE};
    @list   = @_;
  }
  return splice @{$self->{ARRAY}}, $offset, $length, @list;
}
]]></verbatim>
</item>
<item><itemtext>UNTIE this
<index>UNTIE</index></itemtext>
<para>
Will be called when <code>untie</code> happens. (See <link xref='The {tag:code>untie{#tag:code} Gotcha'}The <code>untie</code> Gotcha</link> below.)
</para>
<para>
<code>untie</code> が起きると呼び出されます。
(後述する <link xref='The {tag:code>untie{#tag:code} Gotcha'}The <code>untie</code> Gotcha</link> を参照してください。)
</para>
</item>
<item><itemtext>DESTROY this
<index>DESTROY</index></itemtext>
<para>
This method will be triggered when the tied variable needs to be destructed.
As with the scalar tie class, this is almost never needed in a
language that does its own garbage collection, so this time we'll
just leave it out.
</para>
<para>
このメソッドは tie された変数を破棄する必要があるときに呼び出されます。
スカラを tie したクラスと同様、このメソッドはガベージコレクションを
言語自体が行っているのでほとんど必要ありません。
ですから、今回はこのまま放っておきます。
</para>
</item>
</list>
</sect2>
<sect2>
<title>Tying Hashes
<index>hash, tying</index></title>
<para>
(ハッシュを tie する)
</para>
<para>
Hashes were the first Perl data type to be tied (see dbmopen()).  A class
implementing a tied hash should define the following methods: TIEHASH is
the constructor.  FETCH and STORE access the key and value pairs.  EXISTS
reports whether a key is present in the hash, and DELETE deletes one.
CLEAR empties the hash by deleting all the key and value pairs.  FIRSTKEY
and NEXTKEY implement the keys() and each() functions to iterate over all
the keys. SCALAR is triggered when the tied hash is evaluated in scalar 
context. UNTIE is called when <code>untie</code> happens, and DESTROY is called when
the tied variable is garbage collected.
</para>
<para>
ハッシュは tie される最初の Perl データ型でした(dbmopen() を参照)。
tie されたハッシュを実装するクラスは、以下のメソッドを定義すべきです。
TIEHASH はコンストラクタです。
FETCH と STORE はキーと値のペアにアクセスします。
EXIST はキーがハッシュにあるかどうかを報告し、DELETE はキーを削除します。
CLEAR はすべてのキーと値のペアを削除することによりハッシュを空にします。
FIRSTKEY と NEXTKEY は全てのキーを反復するための関数 keys() と each() を
実装します。
SCALAR は tie されたハッシュがスカラコンテキストで評価されたときに
呼び出されます。
UNTIE は <code>untie</code> が起きたときに呼び出され、DESTROY は tie された変数が
ガーベジコレクションされるときに呼び出されます。
</para>
<para>
If this seems like a lot, then feel free to inherit from merely the
standard Tie::StdHash module for most of your methods, redefining only the
interesting ones.  See <link xref='Tie::Hash'>Tie::Hash</link> for details.
</para>
<para>
もしこれがたくさんありすぎると感じられるのなら、標準の Tie::StdHash
モジュールを単純に継承し、再定義を必要とするものだけを自分で
実装することもできます。
詳しくは <link xref='Tie::Hash'>Tie::Hash</link> を参照してください。
</para>
<para>
Remember that Perl distinguishes between a key not existing in the hash,
and the key existing in the hash but having a corresponding value of
<code>undef</code>.  The two possibilities can be tested with the <code>exists()</code> and
<code>defined()</code> functions.
</para>
<para>
Perl がハッシュに存在していないキーと、ハッシュに存在しているけれども
<code>undef</code> という値を持っているキーとを明確に区別しているということを
忘れないでください。
これら二つの可能性は、<code>exists()</code> と
<code>defined()</code> という関数を使って検査できます。
</para>
<para>
Here's an example of a somewhat interesting tied hash class:  it gives you
a hash representing a particular user's dot files.  You index into the hash
with the name of the file (minus the dot) and you get back that dot file's
contents.  For example:
</para>
<para>
次の例は tie されたハッシュクラスを使ったものです。
この例では特定のユーザーのドットファイルを表わすハッシュを提供します。
あなたはハッシュをファイルの名前(からドットを取り除いたもの)によって
添え字付けを行い、そのドットファイルの内容を取得します。
例えば:
</para>
<verbatim><![CDATA[
use DotFiles;
tie %dot, 'DotFiles';
if ( $dot{profile} =~ /MANPATH/ ||
     $dot{login}   =~ /MANPATH/ ||
     $dot{cshrc}   =~ /MANPATH/    )
{
	print "you seem to set your MANPATH\n";
}
]]></verbatim>
<para>
Or here's another sample of using our tied class:
</para>
<para>
tie されたクラスを使ったもう一つの例です。
</para>
<verbatim><![CDATA[
tie %him, 'DotFiles', 'daemon';
foreach $f ( keys %him ) {
	printf "daemon dot file %s is size %d\n",
	    $f, length $him{$f};
}
]]></verbatim>
<para>
In our tied hash DotFiles example, we use a regular
hash for the object containing several important
fields, of which only the <code>{LIST}</code> field will be what the
user thinks of as the real hash.
</para>
<para>
この DotFiles という tie されたハッシュでは、私たちは <code>{LIST}</code>
フィールドのみをユーザーが本当のハッシュであると考えるであろう幾つかの
重要なフィールドを持ったオブジェクトのために、通常のハッシュを
使いました。
</para>
<list>
<item><itemtext>USER</itemtext>
<para>
whose dot files this object represents
</para>
<para>
このオブジェクトが表わしているドットファイルの所有者
</para>
</item>
<item><itemtext>HOME</itemtext>
<para>
where those dot files live
</para>
<para>
ドットファイルがある場所
</para>
</item>
<item><itemtext>CLOBBER</itemtext>
<para>
whether we should try to change or remove those dot files
</para>
<para>
これらのドットファイルを変更したり削除することをしようとすべきか
を表わすフラグ
</para>
</item>
<item><itemtext>LIST</itemtext>
<para>
the hash of dot file names and content mappings
</para>
<para>
ドットファイルの名前と内容のマッピングをしたハッシュ
</para>
</item>
</list>
<para>
Here's the start of <filename>Dotfiles.pm</filename>:
</para>
<para>
次は <filename>Dotfiles.pm</filename> の先頭です:
</para>
<verbatim><![CDATA[
package DotFiles;
use Carp;
sub whowasi { (caller(1))[3] . '()' }
my $DEBUG = 0;
sub debug { $DEBUG = @_ ? shift : 1 }
]]></verbatim>
<para>
For our example, we want to be able to emit debugging info to help in tracing
during development.  We keep also one convenience function around
internally to help print out warnings; whowasi() returns the function name
that calls it.
</para>
<para>
この例では、私たちは開発の間トレースがしやすいようにデバッグ情報を
出力できるようにしたいと考えました。
同様に、警告を出力するのを助ける一つの便利な内部関数を残しました。
whowasi() は呼び出した関数の名前を返します。
</para>
<para>
Here are the methods for the DotFiles tied hash.
</para>
<para>
以下は、DotoFiles に tie されたハッシュのためのメソッドです。
</para>
<list>
<item><itemtext>TIEHASH classname, LIST
<index>TIEHASH</index></itemtext>
<para>
This is the constructor for the class.  That means it is expected to
return a blessed reference through which the new object (probably but not
necessarily an anonymous hash) will be accessed.
</para>
<para>
これはクラスに対するコンストラクタです。
その役割は、アクセスされる(おそらくは無名のハッシュ、
ただしそうする必要はない)オブジェクトへの bless された参照を返すことです。
</para>
<para>
Here's the constructor:
</para>
<para>
コンストラクタの例です。
</para>
<verbatim><![CDATA[
sub TIEHASH {
	my $self = shift;
	my $user = shift || $>;
	my $dotdir = shift || '';
	croak "usage: @{[&whowasi]} [USER [DOTDIR]]" if @_;
	$user = getpwuid($user) if $user =~ /^\d+$/;
	my $dir = (getpwnam($user))[7]
		|| croak "@{[&whowasi]}: no user $user";
	$dir .= "/$dotdir" if $dotdir;
]]></verbatim>
<verbatim><![CDATA[
my $node = {
    USER    => $user,
    HOME    => $dir,
    LIST    => {},
    CLOBBER => 0,
};
]]></verbatim>
<verbatim><![CDATA[
opendir(DIR, $dir)
	|| croak "@{[&whowasi]}: can't opendir $dir: $!";
foreach $dot ( grep /^\./ && -f "$dir/$_", readdir(DIR)) {
    $dot =~ s/^\.//;
    $node->{LIST}{$dot} = undef;
}
closedir DIR;
return bless $node, $self;
    }
]]></verbatim>
<para>
It's probably worth mentioning that if you're going to filetest the
return values out of a readdir, you'd better prepend the directory
in question.  Otherwise, because we didn't chdir() there, it would
have been testing the wrong file.
</para>
<para>
readdir が返した値をつかってファイルテストをしようという場合、
問い合わせにディレクトリを付加すべきでしょう。
そうしなければ、chdir() をしていないので間違ったファイルを
テストしてしまうこととなります。
</para>
</item>
<item><itemtext>FETCH this, key
<index>FETCH</index></itemtext>
<para>
This method will be triggered every time an element in the tied hash is
accessed (read).  It takes one argument beyond its self reference: the key
whose value we're trying to fetch.
</para>
<para>
このメソッドは tie されたハッシュがアクセス(読み出し)される度毎に
呼び出されます。
これは自分の参照のほかに、フェッチしようとしている値に対するキーを、
ただ一つの引数としてとります。
</para>
<para>
Here's the fetch for our DotFiles example.
</para>
<para>
以下に示すのは、私たちの DotFiles サンプルのためのフェッチです。
</para>
<verbatim><![CDATA[
sub FETCH {
	carp &whowasi if $DEBUG;
	my $self = shift;
	my $dot = shift;
	my $dir = $self->{HOME};
	my $file = "$dir/.$dot";
]]></verbatim>
<verbatim><![CDATA[
unless (exists $self->{LIST}->{$dot} || -f $file) {
    carp "@{[&whowasi]}: no $dot file" if $DEBUG;
    return undef;
}
]]></verbatim>
<verbatim><![CDATA[
if (defined $self->{LIST}->{$dot}) {
    return $self->{LIST}->{$dot};
} else {
    return $self->{LIST}->{$dot} = `cat $dir/.$dot`;
}
    }
]]></verbatim>
<para>
It was easy to write by having it call the Unix cat(1) command, but it
would probably be more portable to open the file manually (and somewhat
more efficient).  Of course, because dot files are a Unixy concept, we're
not that concerned.
</para>
<para>
UNIX の cat(1) コマンドを呼んでいるので記述するのは簡単でしたが、
ファイルを自分でオープンすることによってよりポータブル(かつ、より高効率)に
できます。
もちろん、ドットファイルは UNIX 的なコンセプトですから、
私たちは気にしませんでした。
</para>
</item>
<item><itemtext>STORE this, key, value
<index>STORE</index></itemtext>
<para>
This method will be triggered every time an element in the tied hash is set
(written).  It takes two arguments beyond its self reference: the index at
which we're trying to store something, and the value we're trying to put
there.
</para>
<para>
このメソッドは tie されたハッシュの要素がセット(書き込み)される度に
呼び出されます。
これは自分の参照の他に二つの引数、何かを格納しようとする場所の添え字と、
格納しようとする値をとります。
</para>
<para>
Here in our DotFiles example, we'll be careful not to let
them try to overwrite the file unless they've called the clobber()
method on the original object reference returned by tie().
</para>
<para>
以下は DotFiles のサンプルです。
tie() で返されたオブジェクトのリファレンス上で clobber() メソッドが
呼び出されない限り、ファイルを上書きしないようにしています。
</para>
<verbatim><![CDATA[
sub STORE {
	carp &whowasi if $DEBUG;
	my $self = shift;
	my $dot = shift;
	my $value = shift;
	my $file = $self->{HOME} . "/.$dot";
	my $user = $self->{USER};
]]></verbatim>
<verbatim><![CDATA[
croak "@{[&whowasi]}: $file not clobberable"
    unless $self->{CLOBBER};
]]></verbatim>
<verbatim><![CDATA[
open(F, "> $file") || croak "can't open $file: $!";
print F $value;
close(F);
    }
]]></verbatim>
<para>
If they wanted to clobber something, they might say:
</para>
<para>
もし何かを変更したいというのであれば、このようにします。
</para>
<verbatim><![CDATA[
$ob = tie %daemon_dots, 'daemon';
$ob->clobber(1);
$daemon_dots{signature} = "A true daemon\n";
]]></verbatim>
<para>
Another way to lay hands on a reference to the underlying object is to
use the tied() function, so they might alternately have set clobber
using:
</para>
<para>
基礎をなすオブジェクトへの参照を扱うもう一つの方法は tied() 関数を
使うことで、これによって clobber を以下の様に使ってセットできます。
</para>
<verbatim><![CDATA[
tie %daemon_dots, 'daemon';
tied(%daemon_dots)->clobber(1);
]]></verbatim>
<para>
The clobber method is simply:
</para>
<para>
clobber メソッドは単純です。
</para>
<verbatim><![CDATA[
sub clobber {
	my $self = shift;
	$self->{CLOBBER} = @_ ? shift : 1;
}
]]></verbatim>
</item>
<item><itemtext>DELETE this, key
<index>DELETE</index></itemtext>
<para>
This method is triggered when we remove an element from the hash,
typically by using the delete() function.  Again, we'll
be careful to check whether they really want to clobber files.
</para>
<para>
このメソッドはハッシュから要素を取り除くとき、典型的には delete() 関数を
使ったときに呼び出されます。
繰り返しますが、本当にファイルを clobber したいのかを注意深く検査しています。
</para>
<verbatim><![CDATA[
sub DELETE   {
	carp &whowasi if $DEBUG;
]]></verbatim>
<verbatim><![CDATA[
my $self = shift;
my $dot = shift;
my $file = $self->{HOME} . "/.$dot";
croak "@{[&whowasi]}: won't remove file $file"
    unless $self->{CLOBBER};
delete $self->{LIST}->{$dot};
my $success = unlink($file);
carp "@{[&whowasi]}: can't unlink $file: $!" unless $success;
$success;
    }
]]></verbatim>
<para>
The value returned by DELETE becomes the return value of the call
to delete().  If you want to emulate the normal behavior of delete(),
you should return whatever FETCH would have returned for this key.
In this example, we have chosen instead to return a value which tells
the caller whether the file was successfully deleted.
</para>
<para>
DELETE の 返す値は delete() の戻り値から来ています。
もしあなたが通常の delete() の動作をまねしたいというのであれば、
FETCH がこのキーに対して返すであろう値を返すべきでしょう。
この例では、戻り値としてファイルの削除に成功したかどうかを
返すことを選択しました。
</para>
</item>
<item><itemtext>CLEAR this
<index>CLEAR</index></itemtext>
<para>
This method is triggered when the whole hash is to be cleared, usually by
assigning the empty list to it.
</para>
<para>
このメソッドはハッシュ全体が消去されるとき、通常は空リストが代入されたときに
呼び出されます。
</para>
<para>
In our example, that would remove all the user's dot files!  It's such a
dangerous thing that they'll have to set CLOBBER to something higher than
1 to make it happen.
</para>
<para>
私たちの例では、これはユーザーのすべてのドットファイルを
削除してしまいます!
これはとても危険なことで、実際に削除するには CLOBBER に 1 を超える値を
セットすることが必要となります。
</para>
<verbatim><![CDATA[
sub CLEAR    {
	carp &whowasi if $DEBUG;
	my $self = shift;
	croak "@{[&whowasi]}: won't remove all dot files for $self->{USER}"
	    unless $self->{CLOBBER} > 1;
	my $dot;
	foreach $dot ( keys %{$self->{LIST}}) {
	    $self->DELETE($dot);
	}
}
]]></verbatim>
</item>
<item><itemtext>EXISTS this, key
<index>EXISTS</index></itemtext>
<para>
This method is triggered when the user uses the exists() function
on a particular hash.  In our example, we'll look at the <code>{LIST}</code>
hash element for this:
</para>
<para>
このメソッドは特定のハッシュにおいて、exists() 関数が使われたときに
呼び出されます。
私たちの例では、このためにハッシュ要素 <code>{LIST}</code> を参照します。
</para>
<verbatim><![CDATA[
sub EXISTS   {
	carp &whowasi if $DEBUG;
	my $self = shift;
	my $dot = shift;
	return exists $self->{LIST}->{$dot};
}
]]></verbatim>
</item>
<item><itemtext>FIRSTKEY this
<index>FIRSTKEY</index></itemtext>
<para>
This method will be triggered when the user is going
to iterate through the hash, such as via a keys() or each()
call.
</para>
<para>
このメソッドは keys() や each() を呼び出すのと同様に、ハッシュを通じた
反復をユーザーが行おうとするときに呼び出されます。
</para>
<verbatim><![CDATA[
sub FIRSTKEY {
	carp &whowasi if $DEBUG;
	my $self = shift;
	my $a = keys %{$self->{LIST}};		# reset each() iterator
	each %{$self->{LIST}}
}
]]></verbatim>
</item>
<item><itemtext>NEXTKEY this, lastkey
<index>NEXTKEY</index></itemtext>
<para>
This method gets triggered during a keys() or each() iteration.  It has a
second argument which is the last key that had been accessed.  This is
useful if you're carrying about ordering or calling the iterator from more
than one sequence, or not really storing things in a hash anywhere.
</para>
<para>
このメソッドは keys() または each() 反復の間に呼び出されます。
二番目の引数として、最後にアクセスしたキーをとります。
これは、あなたが順番に取り出すとか、二度以上反復子を呼び出したり、
あるいは実際にはハッシュのどこにも格納されていないものであるときに
便利です。
</para>
<para>
For our example, we're using a real hash so we'll do just the simple
thing, but we'll have to go through the LIST field indirectly.
</para>
<para>
私たちの例では本当のハッシュを使うので、やることは簡単です。
しかし、LIST フィールドを間接的に扱わなければなりません。
</para>
<verbatim><![CDATA[
sub NEXTKEY  {
	carp &whowasi if $DEBUG;
	my $self = shift;
	return each %{ $self->{LIST} }
}
]]></verbatim>
</item>
<item><itemtext>SCALAR this
<index>SCALAR</index></itemtext>
<para>
This is called when the hash is evaluated in scalar context. In order
to mimic the behaviour of untied hashes, this method should return a
false value when the tied hash is considered empty. If this method does
not exist, perl will make some educated guesses and return true when
the hash is inside an iteration. If this isn't the case, FIRSTKEY is
called, and the result will be a false value if FIRSTKEY returns the empty
list, true otherwise.
</para>
<para>
これはハッシュがスカラコンテキストで評価されたときに呼び出されます。
tie されていないハッシュの振る舞いを真似るために、tie されたハッシュが空と
考えられる場合は、このメソッドは偽の値を返すべきです。
このメソッドが存在しない場合、perl はいくらかの教育された推測を行い、
ハッシュが反復中である場合は真を返します。
もしそうでない場合は、FIRSTKEY が呼び出され、これが空リストを返した場合は
偽の値を返し、さもなければ真の値を返します。
</para>
<para>
However, you should <strong>not</strong> blindly rely on perl always doing the right 
thing. Particularly, perl will mistakenly return true when you clear the 
hash by repeatedly calling DELETE until it is empty. You are therefore 
advised to supply your own SCALAR method when you want to be absolutely 
sure that your hash behaves nicely in scalar context.
</para>
<para>
しかし、perl が常に正しいことを行うと盲目的に信頼しては <strong>いけません</strong>。
特に、ハッシュが空になるまで繰り返し DELETE を呼び出すことでハッシュを
クリアした場合、perl は間違って真を返します。
従って、ハッシュがスカラコンテキストでもうまく振舞うことを完全に確実に
したい場合は、独自の SCALAR メソッドを作ることを勧めます。
</para>
<para>
In our example we can just call <code>scalar</code> on the underlying hash
referenced by <code>$self-&gt;{LIST}</code>:
</para>
<para>
この例では、<code>$self-&gt;{LIST}</code> でリファレンスされている、元となる
ハッシュで <code>scalar</code> を呼び出しています:
</para>
<verbatim><![CDATA[
sub SCALAR {
	carp &whowasi if $DEBUG;
	my $self = shift;
	return scalar %{ $self->{LIST} }
}
]]></verbatim>
</item>
<item><itemtext>UNTIE this
<index>UNTIE</index></itemtext>
<para>
This is called when <code>untie</code> occurs.  See <link xref='The {tag:code>untie{#tag:code} Gotcha'}The <code>untie</code> Gotcha</link> below.
</para>
<para>
これは <code>untie</code> が発生した時に呼び出されます。
以下の <link xref='The {tag:code>untie{#tag:code} Gotcha'}The <code>untie</code> Gotcha</link> を参照してください。
</para>
</item>
<item><itemtext>DESTROY this
<index>DESTROY</index></itemtext>
<para>
This method is triggered when a tied hash is about to go out of
scope.  You don't really need it unless you're trying to add debugging
or have auxiliary state to clean up.  Here's a very simple function:
</para>
<para>
このメソッドは tie されたハッシュがスコープの外に出るときに
呼び出されます。
実際には、デバッグ情報を足そうとするとか、後始末のための
補助的な情報を持っていなければ、必要になりません。
</para>
<verbatim><![CDATA[
sub DESTROY  {
	carp &whowasi if $DEBUG;
}
]]></verbatim>
</item>
</list>
<para>
Note that functions such as keys() and values() may return huge lists
when used on large objects, like DBM files.  You may prefer to use the
each() function to iterate over such.  Example:
</para>
<para>
keys() や values() といった関数は、DBM ファイルのような大きなオブジェクトに
対して使ったときに大きなリストを返す可能性があるということに
注意してください。
そういったものに対して繰り返しの処理を行うには、each() を使うのが
良いでしょう。
例:
</para>
<verbatim><![CDATA[
# print out history file offsets
use NDBM_File;
tie(%HIST, 'NDBM_File', '/usr/lib/news/history', 1, 0);
while (($key,$val) = each %HIST) {
    print $key, ' = ', unpack('L',$val), "\n";
}
untie(%HIST);
]]></verbatim>
</sect2>
<sect2>
<title>Tying FileHandles
<index>filehandle, tying</index></title>
<para>
(ファイルハンドルを tie する)
</para>
<para>
This is partially implemented now.
</para>
<para>
これは現時点ではまだ部分的にしか実装されていません。
</para>
<para>
A class implementing a tied filehandle should define the following
methods: TIEHANDLE, at least one of PRINT, PRINTF, WRITE, READLINE, GETC,
READ, and possibly CLOSE, UNTIE and DESTROY.  The class can also provide: BINMODE,
OPEN, EOF, FILENO, SEEK, TELL - if the corresponding perl operators are
used on the handle.
</para>
<para>
tie されたファイルハンドルを実装するクラスは以下のメソッドを定義すべきです。
TIEHANDLE と、PRINT, PRINTF, WRITE, READLINE, GETC, READ の
中の少なくともいずれか一つ、そして可能であればCLOSE, UNTIE, DESTROY。
また、クラスは以下のものも提供できます: BINMODE,
OPEN, EOF, FILENO, SEEK, TELL - もし対応する perl の演算子がハンドルで
つかわれるならです。
</para>
<para>
When STDERR is tied, its PRINT method will be called to issue warnings
and error messages.  This feature is temporarily disabled during the call, 
which means you can use <code>warn()</code> inside PRINT without starting a recursive
loop.  And just like <code>__WARN__</code> and <code>__DIE__</code> handlers, STDERR's PRINT
method may be called to report parser errors, so the caveats mentioned under 
<link xref='perlvar#%SIG'>perlvar/%SIG</link> apply.
</para>
<para>
STDERR が tie されると、その PRINT メソッドが、警告とエラーのメッセージを
出力するために呼び出されます。
この機能は呼び出しの最中には一時的に無効にされているので、再帰ループを
作ることなく PRINT の内部で <code>warn()</code> を使えることを意味します。
また、<code>__WARN__</code> や <code>__DIE__</code> のハンドラと同様に、STDERR の
PRINT メソッドはパーサーエラーの報告に呼び出されるので、<link xref='perlvar#%SIG'>perlvar/%SIG</link> で
言及した問題点が適用されます。
</para>
<para>
All of this is especially useful when perl is embedded in some other 
program, where output to STDOUT and STDERR may have to be redirected 
in some special way.  See nvi and the Apache module for examples.
</para>
<para>
これら全ては perl が他のプログラムに埋め込まれていて、
STDOUT や STDERR で出力する場所はなんらかの特殊なやり方でリダイレクトする
必要があるときに特に便利です。
実際の例は nvi や Apache モジュールを参照してください。
</para>
<para>
In our example we're going to create a shouting handle.
</para>
<para>
私たちの例では、叫ぶハンドルを生成します。
</para>
<verbatim><![CDATA[
package Shout;
]]></verbatim>
<list>
<item><itemtext>TIEHANDLE classname, LIST
<index>TIEHANDLE</index></itemtext>
<para>
This is the constructor for the class.  That means it is expected to
return a blessed reference of some sort. The reference can be used to
hold some internal information.
</para>
<para>
これはこのクラスのコンストラクタです。
その働きはなにかの bless されたリファレンスを返すことです。
そのリファレンスは内部情報を保持するために使うことができます。
</para>
<verbatim><![CDATA[
sub TIEHANDLE { print "<shout>\n"; my $i; bless \$i, shift }
]]></verbatim>
</item>
<item><itemtext>WRITE this, LIST
<index>WRITE</index></itemtext>
<para>
This method will be called when the handle is written to via the
<code>syswrite</code> function.
</para>
<para>
このメソッドは <code>syswrite</code> 関数を通じてハンドルが書き出されるときに
呼び出されます。
</para>
<verbatim><![CDATA[
sub WRITE {
	$r = shift;
	my($buf,$len,$offset) = @_;
	print "WRITE called, \$buf=$buf, \$len=$len, \$offset=$offset";
}
]]></verbatim>
</item>
<item><itemtext>PRINT this, LIST
<index>PRINT</index></itemtext>
<para>
This method will be triggered every time the tied handle is printed to
with the <code>print()</code> function.
Beyond its self reference it also expects the list that was passed to
the print function.
</para>
<para>
このメソッドは tie されたハンドルに <code>print</code> 関数を使って出力される
度に呼び出されます。
このメソッドは自分の参照のほか、print 関数に渡すリストを受け取ります。
</para>
<verbatim><![CDATA[
sub PRINT { $r = shift; $$r++; print join($,,map(uc($_),@_)),$\ }
]]></verbatim>
</item>
<item><itemtext>PRINTF this, LIST
<index>PRINTF</index></itemtext>
<para>
This method will be triggered every time the tied handle is printed to
with the <code>printf()</code> function.
Beyond its self reference it also expects the format and list that was
passed to the printf function.
</para>
<para>
このメソッドは tie されたハンドルに <code>printf</code> 関数を使って
出力される度に呼び出されます。
このメソッドは自分の参照のほか、printf 関数に渡すリストを受け取ります。
</para>
<verbatim><![CDATA[
sub PRINTF {
    shift;
    my $fmt = shift;
    print sprintf($fmt, @_);
}
]]></verbatim>
</item>
<item><itemtext>READ this, LIST
<index>READ</index></itemtext>
<para>
This method will be called when the handle is read from via the <code>read</code>
or <code>sysread</code> functions.
</para>
<para>
このメソッドはハンドルが <code>read</code> や <code>sysread</code> といった関数を通じて
読まれたときに呼び出されます。
</para>
<verbatim><![CDATA[
sub READ {
	my $self = shift;
	my $bufref = \$_[0];
	my(undef,$len,$offset) = @_;
	print "READ called, \$buf=$bufref, \$len=$len, \$offset=$offset";
	# add to $$bufref, set $len to number of characters read
	$len;
}
]]></verbatim>
</item>
<item><itemtext>READLINE this
<index>READLINE</index></itemtext>
<para>
This method will be called when the handle is read from via &lt;HANDLE&gt;.
The method should return undef when there is no more data.
</para>
<para>
このメソッドは &lt;HANDLE&gt; を通してハンドルが読まれたときに呼び出されます。
このメソッドはもうデータがない場合には undef を返します。
</para>
<verbatim><![CDATA[
sub READLINE { $r = shift; "READLINE called $$r times\n"; }
]]></verbatim>
</item>
<item><itemtext>GETC this
<index>GETC</index></itemtext>
<para>
This method will be called when the <code>getc</code> function is called.
</para>
<para>
このメソッドは関数 <code>getc</code> が呼ばれたときに呼び出されます。
</para>
<verbatim><![CDATA[
sub GETC { print "Don't GETC, Get Perl"; return "a"; }
]]></verbatim>
</item>
<item><itemtext>CLOSE this
<index>CLOSE</index></itemtext>
<para>
This method will be called when the handle is closed via the <code>close</code>
function.
</para>
<para>
このメソッドは、<code>close</code> 関数を通してハンドルがクローズされるときに
呼び出されます。
</para>
<verbatim><![CDATA[
sub CLOSE { print "CLOSE called.\n" }
]]></verbatim>
</item>
<item><itemtext>UNTIE this
<index>UNTIE</index></itemtext>
<para>
As with the other types of ties, this method will be called when <code>untie</code> happens.
It may be appropriate to &quot;auto CLOSE&quot; when this occurs.  See
<link xref='The {tag:code>untie{#tag:code} Gotcha'}The <code>untie</code> Gotcha</link> below.
</para>
<para>
その他の種類の tie と同様に、このメソッドは <code>untie</code> が起きたときに
呼び出されます。
これが起きたときに、「自動 CLOSE」を行うのに適切です。
後述する <link xref='The {tag:code>untie{#tag:code} Gotcha'}The <code>untie</code> Gotcha</link> を参照してください。
</para>
</item>
<item><itemtext>DESTROY this
<index>DESTROY</index></itemtext>
<para>
As with the other types of ties, this method will be called when the
tied handle is about to be destroyed. This is useful for debugging and
possibly cleaning up.
</para>
<para>
他の型に対する tie と同様に、このメソッドは tie されたハンドルが
破棄されるときに呼び出されます。
これはデバッグや後始末をするのに便利です。
</para>
<verbatim><![CDATA[
sub DESTROY { print "</shout>\n" }
]]></verbatim>
</item>
</list>
<para>
Here's how to use our little example:
</para>
<para>
以下は私たちのサンプルをどのように使うかの例です。
</para>
<verbatim><![CDATA[
tie(*FOO,'Shout');
print FOO "hello\n";
$a = 4; $b = 6;
print FOO $a, " plus ", $b, " equals ", $a + $b, "\n";
print <FOO>;
]]></verbatim>
</sect2>
<sect2>
<title>UNTIE this
<index>UNTIE</index></title>
<para>
You can define for all tie types an UNTIE method that will be called
at untie().  See <link xref='The {tag:code>untie{#tag:code} Gotcha'}The <code>untie</code> Gotcha</link> below.
</para>
<para>
全ての型に対する tie について、untie() で呼び出される UNTIE メソッドを
定義できます。
以下の <link xref='The {tag:code>untie{#tag:code} Gotcha'}The <code>untie</code> Gotcha</link> を参照してください。
</para>
</sect2>
<sect2>
<title>The <code>untie</code> Gotcha
<index>untie</index></title>
<para>
(<code>untie</code> のコツ)
</para>
<para>
If you intend making use of the object returned from either tie() or
tied(), and if the tie's target class defines a destructor, there is a
subtle gotcha you <emphasis>must</emphasis> guard against.
</para>
<para>
tie() や tied() が返したオブジェクトを使おうとするならば、また、
その tie されているターゲットクラスがデストラクタを
定義しているのであれば、あなたが <emphasis>しなければならない</emphasis>
微妙なコツがあります。
</para>
<para>
As setup, consider this (admittedly rather contrived) example of a
tie; all it does is use a file to keep a log of the values assigned to
a scalar.
</para>
<para>
セットアップとして、以下の tie の例を考えてみましょう。
これはファイルを使って、スカラに代入された値を記録し続けるというものです。
</para>
<verbatim><![CDATA[
package Remember;
]]></verbatim>
<verbatim><![CDATA[
use strict;
use warnings;
use IO::File;
]]></verbatim>
<verbatim><![CDATA[
sub TIESCALAR {
    my $class = shift;
    my $filename = shift;
    my $handle = IO::File->new( "> $filename" )
                     or die "Cannot open $filename: $!\n";
]]></verbatim>
<verbatim><![CDATA[
print $handle "The Start\n";
bless {FH => $handle, Value => 0}, $class;
    }
]]></verbatim>
<verbatim><![CDATA[
sub FETCH {
    my $self = shift;
    return $self->{Value};
}
]]></verbatim>
<verbatim><![CDATA[
sub STORE {
    my $self = shift;
    my $value = shift;
    my $handle = $self->{FH};
    print $handle "$value\n";
    $self->{Value} = $value;
}
]]></verbatim>
<verbatim><![CDATA[
sub DESTROY {
    my $self = shift;
    my $handle = $self->{FH};
    print $handle "The End\n";
    close $handle;
}
]]></verbatim>
<verbatim><![CDATA[
1;
]]></verbatim>
<para>
Here is an example that makes use of this tie:
</para>
<para>
次に挙げるのは、この tie を使った例です。
</para>
<verbatim><![CDATA[
use strict;
use Remember;
]]></verbatim>
<verbatim><![CDATA[
my $fred;
tie $fred, 'Remember', 'myfile.txt';
$fred = 1;
$fred = 4;
$fred = 5;
untie $fred;
system "cat myfile.txt";
]]></verbatim>
<para>
This is the output when it is executed:
</para>
<para>
これを実行したときの出力は次のようになります。
</para>
<verbatim><![CDATA[
The Start
1
4
5
The End
]]></verbatim>
<para>
So far so good.  Those of you who have been paying attention will have
spotted that the tied object hasn't been used so far.  So lets add an
extra method to the Remember class to allow comments to be included in
the file -- say, something like this:
</para>
<para>
まずまずですね。
注意深い人は tie されたオブジェクトがここでは使われていないことを
指摘するでしょう。
そこで、Remember クラスにファイルがコメントを含むことを
できるようにするメソッドを追加しましょう -- そう、このような:
</para>
<verbatim><![CDATA[
sub comment {
    my $self = shift;
    my $text = shift;
    my $handle = $self->{FH};
    print $handle $text, "\n";
}
]]></verbatim>
<para>
And here is the previous example modified to use the <code>comment</code> method
(which requires the tied object):
</para>
<para>
次の例は、前の例を <code>comment</code> メソッド(tie されたオブジェクトを
必要とします)を使うために変更したものです。
</para>
<verbatim><![CDATA[
use strict;
use Remember;
]]></verbatim>
<verbatim><![CDATA[
my ($fred, $x);
$x = tie $fred, 'Remember', 'myfile.txt';
$fred = 1;
$fred = 4;
comment $x "changing...";
$fred = 5;
untie $fred;
system "cat myfile.txt";
]]></verbatim>
<para>
When this code is executed there is no output.  Here's why:
</para>
<para>
このコードを実行したとき、なにも出力されません。
その理由はこうです。
</para>
<para>
When a variable is tied, it is associated with the object which is the
return value of the TIESCALAR, TIEARRAY, or TIEHASH function.  This
object normally has only one reference, namely, the implicit reference
from the tied variable.  When untie() is called, that reference is
destroyed.  Then, as in the first example above, the object's
destructor (DESTROY) is called, which is normal for objects that have
no more valid references; and thus the file is closed.
</para>
<para>
変数が tie されたとき、それは TIESCALAR, TIEARRAY, TIEHASH といった
関数のいずれかの返した値であるオブジェクトに結び付けられます。
このオブジェクトは、通常はただ一つのリファレンス、すなわち tie され
た変数からの暗黙のリファレンスだけを持っています。
untile() が呼ばれたとき、このリファレンスは破棄されます。
したがって、最初の例にあったように、オブジェクトのデストラクタ (DESTROY) が
呼び出されてオブジェクトはもはや正当なリファレンスを持たないようになり、
さらにファイルがクローズされます。
</para>
<para>
In the second example, however, we have stored another reference to
the tied object in $x.  That means that when untie() gets called
there will still be a valid reference to the object in existence, so
the destructor is not called at that time, and thus the file is not
closed.  The reason there is no output is because the file buffers
have not been flushed to disk.
</para>
<para>
しかしながら二番目の例においては、私たちはもう一つの tie された
オブジェクトへのリファレンスを $x の中に格納しました。
これは untie() されたときに、存在するオブジェクトに対する正当な
リファレンスがまだ存在しているということです。
このためデストラクタはその時には呼び出されません。
そしてファイルはクローズされないのです。
何の出力も無かった理由は、ファイルバッファがディスクに
フラッシュされていなかったからです。
</para>
<para>
Now that you know what the problem is, what can you do to avoid it?
Prior to the introduction of the optional UNTIE method the only way
was the good old <code>-w</code> flag. Which will spot any instances where you call
untie() and there are still valid references to the tied object.  If
the second script above this near the top <code>use warnings 'untie'</code>
or was run with the <code>-w</code> flag, Perl prints this
warning message:
</para>
<para>
さて、あなたはもうこれが問題であることがわかったでしょう。
では、これを避けるにはどうすればいいでしょうか?
省略可能な UNTIE メソッドが導入される前は、唯一の方法は
古き良き <code>-w</code> オプションだけです。
これははあなたが untie() を呼んだそのときに、(untie() の対象となっている)
tie されたオブジェクトに対する正当なリファレンスがまだ存在している場合には
それを指摘してくれます。
もし二番目のスクリプトを先頭の方に <code>use warnings 'untie'</code> を付けるか、
<code>-w</code> オプションをつけた状態で実行していれば、
Perl は次のような警告メッセージを出力します。
</para>
<verbatim><![CDATA[
untie attempted while 1 inner references still exist
]]></verbatim>
<para>
To get the script to work properly and silence the warning make sure
there are no valid references to the tied object <emphasis>before</emphasis> untie() is
called:
</para>
<para>
スクリプトを正しく動作させ、警告を黙らせるには tie されたオブジェクトが
untie() を呼び出すより <emphasis>前に</emphasis> 正当なリファレンスをなくすようにします。
</para>
<verbatim><![CDATA[
undef $x;
untie $fred;
]]></verbatim>
<para>
Now that UNTIE exists the class designer can decide which parts of the
class functionality are really associated with <code>untie</code> and which with
the object being destroyed. What makes sense for a given class depends
on whether the inner references are being kept so that non-tie-related
methods can be called on the object. But in most cases it probably makes
sense to move the functionality that would have been in DESTROY to the UNTIE
method.
</para>
<para>
今や UNTIE が存在するので、クラスデザイナーはクラス機能のどの部分が
本当に <code>untie</code> に関連付けられ、どの部分がオブジェクトが破壊されたときに
関連付けられるかを決定できます。
与えられたクラスについてどんな意味があるかは内部のリファレンスが
維持されているかどうかに依存しているので、tie に関係ないメソッドは
オブジェクトで呼び出しできます。
しかし、ほとんどの場合、DESTROY にある機能を UNTIE メソッドに移すのが
意味のあることでしょう。
</para>
<para>
If the UNTIE method exists then the warning above does not occur. Instead the
UNTIE method is passed the count of &quot;extra&quot; references and can issue its own
warning if appropriate. e.g. to replicate the no UNTIE case this method can
be used:
</para>
<para>
もし UNTIE メソッドが存在するなら、上記の警告は起こりません。
代わりに UNTIE メソッドは「追加の」リファレンスの数が渡され、もし適切なら
自身の警告を出力できます; 例えば、UNTIE がない場合を複製するには、
このメソッドが使えます:
</para>
<verbatim><![CDATA[
sub UNTIE
{
 my ($obj,$count) = @_;
 carp "untie attempted while $count inner references still exist" if $count;
}
]]></verbatim>
</sect2>
</sect1>
<sect1>
<title>SEE ALSO</title>
<para>
See <link xref='DB_File'>DB_File</link> or <link xref='Config'>Config</link> for some interesting tie() implementations.
A good starting point for many tie() implementations is with one of the
modules <link xref='Tie::Scalar'>Tie::Scalar</link>, <link xref='Tie::Array'>Tie::Array</link>, <link xref='Tie::Hash'>Tie::Hash</link>, or <link xref='Tie::Handle'>Tie::Handle</link>.
</para>
<para>
興味深い幾つかの tie() の実装については <link xref='DB_File'>DB_File</link> や <link xref='Config'>Config</link> を
参照してください。
多くの tie() 実装のためのよい開始点は、モジュール <link xref='Tie::Scalar'>Tie::Scalar</link>,
<link xref='Tie::Array'>Tie::Array</link>, <link xref='Tie::Hash'>Tie::Hash</link>, <link xref='Tie::Handle'>Tie::Handle</link> のいずれかです。
</para>
</sect1>
<sect1>
<title>BUGS</title>
<para>
The bucket usage information provided by <code>scalar(%hash)</code> is not
available.  What this means is that using %tied_hash in boolean
context doesn't work right (currently this always tests false,
regardless of whether the hash is empty or hash elements).
</para>
<para>
<code>scalar(%hash)</code> で提供されるバケツ使用情報は利用できません。
これが意味することは、真偽値コンテキストで %tied_hash を使っても正しく
動作しないということです(現在のところ、ハッシュが空かハッシュ要素かに
関わらず、このテストは常に偽となります)。
</para>
<para>
Localizing tied arrays or hashes does not work.  After exiting the
scope the arrays or the hashes are not restored.
</para>
<para>
配列やハッシュのローカル化は動作しません。
スコープの終了後、配列やハッシュの値は元に戻りません。
</para>
<para>
Counting the number of entries in a hash via <code>scalar(keys(%hash))</code>
or <code>scalar(values(%hash)</code>) is inefficient since it needs to iterate
through all the entries with FIRSTKEY/NEXTKEY.
</para>
<para>
<code>scalar(keys(%hash))</code> や <code>scalar(values(%hash))</code> を使ってハッシュ内の
エントリの数を数えることは非効率的です; 全てのエントリに対して
FIRSTKEY/NEXTKEY を使って反復する必要があるからです。
</para>
<para>
Tied hash/array slices cause multiple FETCH/STORE pairs, there are no
tie methods for slice operations.
</para>
<para>
tie されたハッシュや配列のスライスは複数回の FETCH/STORE の組を引き起こします;
スライス操作のための tie メソッドはありません。
</para>
<para>
You cannot easily tie a multilevel data structure (such as a hash of
hashes) to a dbm file.  The first problem is that all but GDBM and
Berkeley DB have size limitations, but beyond that, you also have problems
with how references are to be represented on disk.  One experimental
module that does attempt to address this need is DBM::Deep.  Check your
nearest CPAN site as described in <link xref='perlmodlib'>perlmodlib</link> for source code.  Note
that despite its name, DBM::Deep does not use dbm.  Another earlier attempt
at solving the problem is MLDBM, which is also available on the CPAN, but
which has some fairly serious limitations.
</para>
<para>
(ハッシュのハッシュのような)複数レベルのデータ構造を dbm ファイルに
tie することは簡単にはできません。
問題は、GDBM と Berkeley DB はサイズに制限があり、それを超えることが
できないということで、また、ディスク上にあるものを参照する方法についても
問題があります。
これを解決しようとしている実験的なモジュールの一つに、
DBM::Deep というものがあります。
ソースコードは <link xref='perlmodlib'>perlmodlib</link> にあるように、
あなたのお近くの CPAN サイトを確かめてください。
その名前にも関わらず、DBM::Deep は DBM を使わないことに注意してください。
問題を解決するためのもう一つの初期の試みは MLDBM で、これも CPAN から
利用可能ですが、かなり重大な制限があります。
</para>
<para>
Tied filehandles are still incomplete.  sysopen(), truncate(),
flock(), fcntl(), stat() and -X can't currently be trapped.
</para>
<para>
ファイルハンドルの tie はまだ不完全です。
現在のところ、sysopen(), truncate(), flock(), fcntl(), stat(), -X は
トラップできません。
</para>
</sect1>
<sect1>
<title>AUTHOR</title>
<para>
Tom Christiansen
</para>
<para>
TIEHANDLE by Sven Verdoolaege &lt;<filename>skimo@dns.ufsia.ac.be</filename>&gt; and Doug MacEachern &lt;<filename>dougm@osf.org</filename>&gt;
</para>
<para>
UNTIE by Nick Ing-Simmons &lt;<filename>nick@ing-simmons.net</filename>&gt;
</para>
<para>
SCALAR by Tassilo von Parseval &lt;<filename>tassilo.von.parseval@rwth-aachen.de</filename>&gt;
</para>
<para>
Tying Arrays by Casey West &lt;<filename>casey@geeknest.com</filename>&gt;
</para>
<para>
Created: KIMURA Koichi
Updated: Kentaro Shirakata &lt;argrath@ub32.org&gt;
</para>
</sect1>
</pod>
