dragonchild has asked for the wisdom of the Perl Monks concerning the following question:
Basically, I want to have an array act as an alias to a sub-array of another array. If it helps, it can be a contiguous slice. I understand that slicing creates a completely new list, unrelated to the old one, so slicing as implemented isn't the answer.
I also know I can use tie for this, but I really want to avoid tie, if at all possible. The application1 of this is going into the refactoring of a heavily-used CPAN module, so performance is more important that a slight memory gain.
Is there a way to alias like I'm talking about? Or is this a Perl6-ism that isn't possible in Perl5? I would think that XS could provide a solution, but I don't know enough about XS to even make a stab at the feasibility of my crackpipe-dreams.
sub foo { my $self = shift; return $self->[ $self->[0] + $foo_offset ]; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (Expert) Splicing a slice
by Roy Johnson (Monsignor) on Sep 28, 2005 at 14:52 UTC | |
|
Re: (Expert) Splicing a slice
by BrowserUk (Patriarch) on Sep 28, 2005 at 16:12 UTC | |
|
Re: (Expert) Splicing a slice
by xdg (Monsignor) on Sep 28, 2005 at 14:52 UTC | |
by xdg (Monsignor) on Sep 28, 2005 at 16:25 UTC | |
by dragonchild (Archbishop) on Sep 28, 2005 at 18:55 UTC | |
by ikegami (Patriarch) on Sep 28, 2005 at 16:40 UTC | |
by xdg (Monsignor) on Sep 28, 2005 at 18:19 UTC | |
|
Re: (Expert) Splicing a slice
by ikegami (Patriarch) on Sep 28, 2005 at 15:14 UTC | |
|
Re: (Expert) Splicing a slice
by diotalevi (Canon) on Sep 28, 2005 at 15:54 UTC | |
|
Re: (Expert) Splicing a slice
by calin (Deacon) on Sep 28, 2005 at 15:58 UTC | |
|
Re: (Expert) Splicing a slice
by ikegami (Patriarch) on Sep 28, 2005 at 15:35 UTC |