NAME
Data::Pointer::HASH - The HASH pointer type
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
The HASH pointer type exists more for completeness than utility. The pointer will be initialised to the first element from a keys
call on the hash that it points to. Since it uses Tie::IxHash
for accessing the hash the order should stay the same if new elements are added via a $p->deref
assignment
METHODS
- assign($hash_ref)
-
Assign the pointer to a different value
p = val
- deref
-
Dereference the pointer or assign to the value it's pointing to
*p *p = val
- incr([$num])
-
Increments the position of the pointer (default is 1)
p++
- decr([$num])
-
Decrements the position of the pointer (default is 1)
p--
- plus($num)
-
Return a pointer by the given offset
p + 1
- minus($num)
-
Return a pointer by the given offset
p - 1
THANKS
Gurusamy Sarathy for the oh so nice Tie::IxHash
AUTHOR
Dan Brook <broquaint@hotmail.com>
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.