Tie::Array



Tie::Array

NAME
SYNOPSIS
DESCRIPTION
CAVEATS
AUTHOR

NAME

Tie::Array − base class for tied arrays

SYNOPSIS

    package Tie::NewArray;
    use Tie::Array;
    @ISA = ('Tie::Array');
    # mandatory methods
    sub TIEARRAY { ... }
    sub FETCH { ... }
    sub FETCHSIZE { ... }
    sub STORE { ... }        # mandatory if elements writeable
    sub STORESIZE { ... }    # mandatory if elements can be added/deleted
    sub EXISTS { ... }       # mandatory if exists() expected to work
    sub DELETE { ... }       # mandatory if delete() expected to work
    # optional methods − for efficiency
    sub CLEAR { ... }
    sub PUSH { ... }
    sub POP { ... }
    sub SHIFT { ... }
    sub UNSHIFT { ... }
    sub SPLICE { ... }
    sub EXTEND { ... }
    sub DESTROY { ... }
    package Tie::NewStdArray;
    use Tie::Array;
    @ISA = ('Tie::StdArray');
    # all methods provided by default
    package main;
    $object = tie @somearray,'Tie::NewArray';
    $object = tie @somearray,'Tie::StdArray';
    $object = tie @somearray,'Tie::NewStdArray';

DESCRIPTION

This module provides methods for array-tying classes. See perltie for a list of the functions required in order to tie an array to a package. The basic Tie::Array package provides stub "DESTROY", and "EXTEND" methods that do nothing, stub "DELETE" and "EXISTS" methods that croak() if the delete() or exists() builtins are ever called on the tied array, and implementations of "PUSH", "POP", "SHIFT", "UNSHIFT", "SPLICE" and "CLEAR" in terms of basic "FETCH", "STORE", "FETCHSIZE", "STORESIZE".

The Tie::StdArray package provides efficient methods required for tied arrays which are implemented as blessed references to an "inner" perl array. It inherits from Tie::Array, and should cause tied arrays to behave exactly like standard arrays, allowing for selective overloading of methods.

For developers wishing to write their own tied arrays, the required methods are briefly defined below. See the perltie section for more detailed descriptive, as well as example code:
TIEARRAY classname, LIST

The class method is invoked by the command "tie @array, classname". Associates an array instance with the specified class. "LIST" would represent additional arguments (along the lines of AnyDBM_File and compatriots) needed to complete the association. The method should return an object of a class which provides the methods below.

STORE this, index, value

Store datum value into index for the tied array associated with object this. If this makes the array larger then class’s mapping of "undef" should be returned for new positions.

FETCH this, index

Retrieve the datum in index for the tied array associated with object this.

FETCHSIZE this

Returns the total number of items in the tied array associated with object this. (Equivalent to "scalar(@array)").

STORESIZE this, count

Sets the total number of items in the tied array associated with object this to be count. If this makes the array larger then class’s mapping of "undef" should be returned for new positions. If the array becomes smaller then entries beyond count should be deleted.

EXTEND this, count

Informative call that array is likely to grow to have count entries. Can be used to optimize allocation. This method need do nothing.

EXISTS this, key

Verify that the element at index key exists in the tied array this.

The Tie::Array implementation is a stub that simply croaks.

DELETE this, key

Delete the element at index key from the tied array this.

The Tie::Array implementation is a stub that simply croaks.

CLEAR this

Clear (remove, delete, ...) all values from the tied array associated with object this.

DESTROY this

Normal object destructor method.

PUSH this, LIST

Append elements of LIST to the array.

POP this

Remove last element of the array and return it.

SHIFT this

Remove the first element of the array (shifting other elements down) and return it.

UNSHIFT this, LIST

Insert LIST elements at the beginning of the array, moving existing elements up to make room.

SPLICE this, offset, length, LIST

Perform the equivalent of "splice" on the array.

offset is optional and defaults to zero, negative values count back from the end of the array.

length is optional and defaults to rest of the array.

LIST may be empty.

Returns a list of the original length elements at offset.

CAVEATS

There is no support at present for tied @ISA. There is a potential conflict between magic entries needed to notice setting of @ISA, and those needed to implement ’tie’.

Very little consideration has been given to the behaviour of tied arrays when $[ is not default value of zero.

AUTHOR

Nick Ing-Simmons <nik@tiuk.ti.com>






Opportunity


Personal Opportunity - Free software gives you access to billions of dollars of software at no cost. Use this software for your business, personal use or to develop a profitable skill. Access to source code provides access to a level of capabilities/information that companies protect though copyrights. Open source is a core component of the Internet and it is available to you. Leverage the billions of dollars in resources and capabilities to build a career, establish a business or change the world. The potential is endless for those who understand the opportunity.

Business Opportunity - Goldman Sachs, IBM and countless large corporations are leveraging open source to reduce costs, develop products and increase their bottom lines. Learn what these companies know about open source and how open source can give you the advantage.





Free Software


Free Software provides computer programs and capabilities at no cost but more importantly, it provides the freedom to run, edit, contribute to, and share the software. The importance of free software is a matter of access, not price. Software at no cost is a benefit but ownership rights to the software and source code is far more significant.


Free Office Software - The Libre Office suite provides top desktop productivity tools for free. This includes, a word processor, spreadsheet, presentation engine, drawing and flowcharting, database and math applications. Libre Office is available for Linux or Windows.





Free Books


The Free Books Library is a collection of thousands of the most popular public domain books in an online readable format. The collection includes great classical literature and more recent works where the U.S. copyright has expired. These books are yours to read and use without restrictions.


Source Code - Want to change a program or know how it works? Open Source provides the source code for its programs so that anyone can use, modify or learn how to write those programs themselves. Visit the GNU source code repositories to download the source.





Education


Study at Harvard, Stanford or MIT - Open edX provides free online courses from Harvard, MIT, Columbia, UC Berkeley and other top Universities. Hundreds of courses for almost all major subjects and course levels. Open edx also offers some paid courses and selected certifications.


Linux Manual Pages - A man or manual page is a form of software documentation found on Linux/Unix operating systems. Topics covered include computer programs (including library and system calls), formal standards and conventions, and even abstract concepts.