in reply to Re^4: a referencable array slice (so assigning to it modifes the original)
in thread a referencable array slice (so assigning to it modifes the original)
What exactly are you trying to achieve? Do you want to be able to take an alias to a contiguous slice of one array and then be able to expand the aliased view, and have the original expand as well?
original: (1, 2, 3, 4, 5) | | alias: (2, 3, 4) push @alias, (a,b,c); alias: (2, 3, 4, a, b, c) | | original: (1, 2, 3, 4, a, b, c, 5)
If that's the behavior you are looking for Data::Alias won't do it. An array slice can refer to any set of indexes in any order from the original. So it is impossible to define where the start and end of the array are within the orignal array. @foo = @bar[5,1,1,5] is perfectly legal. Where do shift and push operate on @foo if it is aliased?
You could probably make something like this work using a tie or something. You'd need to be careful about keeping the idea of start and end of array very clear. I doubt you will find something already written to handle this case.
TGI says moo
|
|---|