NAME

Data::Pointer - Implementation of the concept of C pointers for perl data types

SYNOPSIS

  use Data::Pointer qw(ptr);

  my $var = [ qw( a list of words ) ];
  my $ptr = ptr( $var );

  print $ptr->plus(1)->deref;           # listofwords
  print scalar $ptr->plus(1)->deref;    # list

  $ptr->deref = "foo";                  # $var->[0] eq 'foo'

DESCRIPTION

Have you ever used pointers in C? Well then using this module should be pretty straight-forward. It implements the basic set of pointer operations which I thought to be useful. Currently 4 of the basic perl data types are implemented (which are SCALAR, ARRAY, HASH and IO[1]) and should behave in an intuitive manner which is also documented in their respective docs.

[1] IO is really a GLOB at this point, although eventually I'd like to implement GLOB pointers if it's at all feasible

METHODS

new(%options)

The class constructor method (see. mutant for the object constructor method) It takes arguments in the form of key value pairs and takes the following parameters

value   => What the pointer will be pointing, doesn't have to be a reference
type    => The type of pointer e.g SCALAR
subtype => The subtype of the type of pointer e.g CHAR
size    => Amount of memory to allocate (NOTE: not currently used)
fatal   => If set, the program will die if a pointer goes out of bounds
mutant(%options)

Will mutate the object according to the given parameters

EXPORT_OK

ptr($val[, %options])

A wrapper around new(). Just provide it with a value and it'll return the correct pointer object.

char_ptr($string[, %options])

Creates a character pointer

AUTHOR

Dan Brook <broquaint@hotmail.com>

SEE ALSO

K&R, Tie::File

COPYRIGHT

Copyright (c) 2002, Dan Brook. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.