## Limitation of Array

Expand Messages
• How many elements can be stored in an array? I mean, is there any maximum limit for an array? If anybody knows, please answer. Thanks in advance Vijay
Message 1 of 4 , Mar 5, 2008
How many elements can be stored in an array? I mean, is there any

Vijay
• ... Vijaya How many elements can be stored in an array? I mean, is there any Vijaya maximum limit for an array? If anybody knows, please answer. Perl imposes
Message 2 of 4 , Mar 6, 2008
>>>>> "Vijaya" == Vijaya Kumar <mp_vijayakumar@...> writes:

Vijaya> How many elements can be stored in an array? I mean, is there any

Perl imposes no limits, but it's certainly limited to whatever fits into the
addressing space of a process on your system, because data is all
memory-resident.

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
• From: merlyn@stonehenge.com ... I kinda doubt it. The index of an array is an integer so I d expect the maximum limit to be your size of integers. Which means
Message 3 of 4 , Mar 6, 2008
From: merlyn@...
> >>>>> "Vijaya" == Vijaya Kumar <mp_vijayakumar@...> writes:
>
> Vijaya> How many elements can be stored in an array? I mean, is there any
> Vijaya> maximum limit for an array? If anybody knows, please answer.
>
> Perl imposes no limits, but it's certainly limited to whatever fits into the
> addressing space of a process on your system, because data is all
> memory-resident.

I kinda doubt it. The index of an array is an integer so I'd expect
the maximum limit to be your size of integers.

Which means
use Config;
\$maxint = 2 ** (\$Config{intsize}*8 - 1);

The limit looks way big enough so I doubt Perl bothers to check
whether it needs to promote to something bigger as the array grows.

Jenda
===== Jenda@... === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery
• ... Jenda From: merlyn@stonehenge.com ... Vijaya How many elements can be stored in an array? I mean, is there any Vijaya maximum limit for an array? If
Message 4 of 4 , Mar 6, 2008
>>>>> "Jenda" == Jenda Krynicky <Jenda@...> writes:

Jenda> From: merlyn@...
>> >>>>> "Vijaya" == Vijaya Kumar <mp_vijayakumar@...> writes:
>>
Vijaya> How many elements can be stored in an array? I mean, is there any
>>
>> Perl imposes no limits, but it's certainly limited to whatever fits into the
>> addressing space of a process on your system, because data is all
>> memory-resident.

Jenda> I kinda doubt it. The index of an array is an integer so I'd expect
Jenda> the maximum limit to be your size of integers.

Jenda> Which means
Jenda> use Config;
Jenda> \$maxint = 2 ** (\$Config{intsize}*8 - 1);

Jenda> The limit looks way big enough so I doubt Perl bothers to check
Jenda> whether it needs to promote to something bigger as the array grows.

But I believe the standard "integer" size is always supposed to exceed the
number of addressable bytes for a given architecture. Given that each Perl
Scalar is some number (16?) bytes at a minimum, you already lose a few bits
worth of the number of possible scalars, so I think you're in the clear.

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
Your message has been successfully submitted and would be delivered to recipients shortly.