NAME

Data::Pointer::SCALAR - The SCALAR pointer type

SYNOPSIS

  use Data::Pointer qw(ptr);

  my $ptr = ptr( 'foo bar baz' );

  print $ptr->plus(4)->deref, $/;                # bar baz

  $ptr->incr(4)->deref = 'quux';
  print "yup", $/ if $ptr->deref eq 'foo quux';  # yup

DESCRIPTION

The SCALAR pointer type is implemented much like strings are in C. However the default behaviour is to point to a string and not an array of chars. You can get C string-like behaviour by EXPORTing char_ptr or passing TYPE => 'Char' to the constructer (be it new or ptr).

METHODS

assign($scalar)

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

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.