in reply to equivalent to Hash::Util for lists / arrays

Is there an equivalent to Hash::Util for arrays?
The SEE ALSO section of Hash::Util lists List::Util, which is also a Core module.

The SEE ALSO section of List::Util lists List::MoreUtils, but is not a Core module.

  • Comment on Re: equivalent to Hash::Util for lists / arrays

Replies are listed 'Best First'.
Re^2: equivalent to Hash::Util for lists / arrays
by Anonyrnous Monk (Hermit) on Dec 21, 2010 at 15:21 UTC

    ...but I think neither of these two has the functionality the OP is specifically looking for, i.e. to lock an array against modification.

      The question was so poorly phrased that I was reluctant to reply, and IMHO toolic willently ignored it and chose the second best approach, the "anal tactic" of a "stubborn" reply... ;-)

      We can only speculate about the use case, but IIRC it's possible to define readonly lists with the constant pragma and use them with indices like arrays.

      UPDATE:

      use constant WEEKDAYS => qw( Sunday Monday Tuesday Wednesday Thursday Friday Saturday ); print "Today is ", (WEEKDAYS)[ (localtime)[WDAY] ], ".\n";

      and it's also possible to use read-only values for arrays.

      Cheers Rolf

        constant only makes the direct value a constant. Anything that might be referenced by those scalars are not made constant.