I am trying to achieve the following functionality: I have an inside-out class where the underlying data structures of the objects are scalar references. I'd like to be able to access the contents referenced by objects from this class as arrays, i.e.:
my $fb = Foo::Bar->new;
$fb-> = 12; # here Foo::Bar::STORE($self,$index,$value) is called
print $fb; # not sure, maybe Foo::Bar=SCALAR(0x1835bfc)?
Along similar lines, I'd like to be able to push @$fb, etc. (which would call the PUSH method). I have perused the documentation for perltie
and I think it must be some combination of that, but the best I could come up with was using:
tie my @array, 'Foo::Bar';
$array = 12; # here Foo::Bar::STORE($self,$index,$value) is called
...which is not really what I want. I want the constructor, data structure (scalar ref) and interface to remain the same, and just add syntax sugar. I'm guessing I have to call TIEARRAY in some way in the new
Thanks for any and all help!