rvosa has asked for the wisdom of the Perl Monks concerning the following question:
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 overload and I think it must be some combination of that, but the best I could come up with was using:use Foo::Bar; my $fb = Foo::Bar->new; $fb->[0] = 12; # here Foo::Bar::STORE($self,$index,$value) is called print $fb; # not sure, maybe Foo::Bar=SCALAR(0x1835bfc)?
...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 constructor?use Foo::Bar; tie my @array, 'Foo::Bar'; $array[0] = 12; # here Foo::Bar::STORE($self,$index,$value) is called
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: tie'ing a scalar as an array?
by Zaxo (Archbishop) on Jul 18, 2006 at 09:21 UTC | |
|
Re: tie'ing a scalar as an array?
by ruoso (Curate) on Jul 18, 2006 at 20:19 UTC | |
by rvosa (Curate) on Jul 19, 2006 at 06:42 UTC | |
by ruoso (Curate) on Jul 19, 2006 at 10:27 UTC | |
by rvosa (Curate) on Jul 20, 2006 at 08:32 UTC | |
by ruoso (Curate) on Jul 20, 2006 at 09:30 UTC | |
by rvosa (Curate) on Jul 18, 2006 at 20:43 UTC | |
by ruoso (Curate) on Jul 19, 2006 at 00:15 UTC | |
by rvosa (Curate) on Jul 19, 2006 at 04:54 UTC | |
by rvosa (Curate) on Jul 19, 2006 at 07:50 UTC | |
|
Re: tie'ing a scalar as an array? (use overload, not tie)
by ysth (Canon) on Jul 19, 2006 at 01:19 UTC |