Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Fixed Array size
by jryan (Vicar) on Sep 12, 2002 at 21:27 UTC | |
Update: Accidentally mixed up carp and croak. Fixed. | [reply] [d/l] [select] |
by theorbtwo (Prior) on Sep 12, 2002 at 21:49 UTC | |
Careful, jryan, there are uses of SPLICE that are valid for fixed-length arrays, to whit, where scalar(@list)==$length. Also, BTW, for a very different implementation of this same idea, read perltie; the example for arrays is none other then a length-limited array. (Not quite the same thing -- this requires there always be exactly N elements; the class in perltie requires there be at most N elements. The difference is rather pendatic.) Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by responing to this node). | [reply] |
by jryan (Vicar) on Sep 12, 2002 at 22:10 UTC | |
| [reply] |
|
Re: Fixed Array size
by dws (Chancellor) on Sep 12, 2002 at 21:03 UTC | |
If you really want a fixed-size array, you can simulate one using tie by writing a package that enforces a size restriction.
| [reply] [d/l] |