Overloading won't be necessary. You can tie an array to your Foo::Bar object by defining the methods Foo::Bar::TIEARRAY(), Foo::Bar::FETCH, Foo::Bar::STORE(), etc. They will all look like ordinary instance methods except TIEARRAY(), which looks like a class constructor method.
It's not difficult to write methods which tie an array to an array reference. The methods' arguments can be found in perltie. For example,
All the methods will be equally trivial. You'll need to define most all of the operator methods (POP(), PUSH(), SPLICE(), . . .) to get full array syntax.# args: self, index, value sub STORE { my ($self, $index, $value) = @_; $self->[$index] = $value; }
The tied operator returns the tied object, so you can call the Foo::Bar::baz() method on your array by,
tied(@array)->baz();
After Compline,
Zaxo
In reply to Re: tie'ing a scalar as an array?
by Zaxo
in thread tie'ing a scalar as an array?
by rvosa
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |