vaas_m has asked for the wisdom of the Perl Monks concerning the following question:

Hello Friends, When I am using the Bit Vector Array module, I am facing a small problem. Here is the example
use Bit::Vector::Array; bva(my @my_array); $#my_array=15; print @my_array;
output is 1111000000000000 . It is printing it in the reverse way. One more : When I am doing this way,as follows
use Bit::Vector::Array; bva(my @my_array); @my_array=15; print @my_array;
output is 10. Can any one tell me 1) What is the difference in initialising as @my_array = value ; and $#my_array = value ? 2) In the first case why is it printing in reverse order?

Replies are listed 'Best First'.
Re: usage of Bit vector Array in perl
by diotalevi (Canon) on Mar 22, 2006 at 14:43 UTC

    The latter, @array = 15, is equivalent to the two operations "clear the array, store the value 15 in the first position." The former is "pre-extend or truncate the array so it has 15 elements." That's how things work with regular arrays. I've never used Bit::Vector::Array and can't advice on that. I've just told you how arrays in perl normally work. I use vec() for this kind of task normally.

    As for "backwards" and "forwards," it appears the author has chosen to give you the data with the most significant bits first.

    ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

      The former is "pre-extend or truncate the array so it has 15 elements

      Isn't that 16 elements?