View on
Sam Tregar > Tie-IntegerArray > Tie::IntegerArray



Annotate this POD

View/Report Bugs
Module Version: 0.01   Source  


Tie::IntegerArray - provides a tied array of packed integers of any bit length


  use Tie::IntegerArray;

  # an array of signed 16-bit integers with no undef support and
  # starting room for 100,000 items.  You can expect this to consume a
  # bit more than 200K of memory versus more than 800K for a normal
  # Perl array.
  my @integer_array;
  tie @integer_array, 'Tie::IntegerArray',
     bits => 16,
     signed => 1,
     undef => 0,
     size => 100_000;
  # put a value in
  $integer_array[0] = 10;

  # and print it out
  print "Int 0: $integer_array[0]\n";     

  # the full range of array operations are available


This module provides an array interface to packed array of integers. A packed array of integers is useful in situations where you need to store a large set of integers in as small a space as possible. Access to the packed array will be significantly slower than access to a normal array but for many applications the reduction in memory usage makes this a good trade-off.


To create an IntegerArray you call tie with a number of optional arguements. These arguements let you fine-tune the storage of your integers. The simplest tie call uses no options:

  my @integer_array;
  tie @integer_array, 'Tie::IntegerArray';

This will create an array of signed integers with the same size as native ints on your platform. By default the array does not support undef - values are 0 by default. This may be ideal for many applications - read below for other options.



This module is functionally complete but not yet fully optimized. It relies on Tie::Array for the more advanced array functions (push, pop, etc) and a native implementation could be faster. If this module proves at all popular then I will definitely move in that direction.


Steffen Beyer - Bit::Vector is pure magic.


Sam Tregar,


HTML::Template : A module for using HTML Templates with Perl Copyright (C) 2000 Sam Tregar (

This module is free software; you can redistribute it and/or modify it under the terms of either:

a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or

b) the "Artistic License" which comes with this module.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either the GNU General Public License or the Artistic License for more details.

You should have received a copy of the Artistic License with this module, in the file ARTISTIC. If not, I'll be glad to provide one.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA



syntax highlighting: