8.215. Tie::Array, Tie::StdArrayProvides methods for array-tying classes. (See the perltie manpage for the functions needed for tying an array to a package.) The basic Tie::Array package provides stub DELETE and EXTEND methods and implements PUSH, POP, SHIFT, UNSHIFT, SPLICE, and CLEAR in terms of basic FETCH, STORE, FETCHSIZE, and STORESIZE. Tie::StdArray inherits from Tie::Array and provides the methods needed for tied arrays implemented as blessed references to an "inner" Perl array. It causes tied arrays to behave like standard arrays, allowing for selective method overloading. See the perltie manpage for more detailed information and for examples. To write your own tied arrays, use the following required methods.
TIEARRAY classname, list Constructor. This method is invoked by the command tie @array , classname. Associates an array instance with the specified class. list represents additional arguments needed to complete the association. Should return an object of a class that provides the remaining methods.
CLEAR this Clears all values from the tied array associated with object this.
DESTROY this Normal object destructor.
EXTEND this, count Doesn't need to do anything. Provides information that the array will likely grow to have count entries.
FETCH this, index Retrieves the data item in index for the tied array associated with object this.
FETCHSIZE this Returns the number of items in the tied array associated with object this.
POP this Removes the last element from the array and returns it.
PUSH this, list Appends elements of list to the array.
SHIFT this Removes and returns the first element of the array, shifting the remaining elements down.
SPLICE this, offset, length, list Performs the equivalent of a splice on the array. Returns a list of the original length elements at the specified offset. The arguments are:
STORE this, index, value Stores value of a data item into index for the tied array associated with object this. If the resulting array is larger than the class's mapping for the array, undef should be returned for new positions.
STORESIZE this, count Sets the total number of items in the tied array associated with object this to count. If this makes the array larger than the class's mapping for the array, then undef should be returned for new positions. If it makes the array smaller than the mapping, then entries beyond count should be deleted.
UNSHIFT this, list Inserts list elements at the beginning of the array, moving existing elements up to make room. Copyright © 2002 O'Reilly & Associates. All rights reserved. |
|