Forum Moderators: coopster & phranque

Message Too Old, No Replies

This Will Drive me Crazy!

What is so magic and erratic about the number 382937924?

         

adni18

2:44 am on Apr 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi. I have a very simple statement to add a value to an array, and whenever I have the number set to 382937924, perl stops running the script there! Why? This is extremely urgent, and I think it is going to drive me nuts!

See here:
$sys[382937924] = "Coalition";

This does not seem to want to execute in perl for some reason. However, perl does want to execute the following:
$sys[38293792] = "Coalition";

Why does it do this, and how can I fix it?

wruppert

3:03 am on Apr 3, 2005 (gmt 0)

10+ Year Member



My ActiveState perl generates an error when attempting this. I would guess perl is trying to allocate memory to create array entries for 0 to 382937923, an array almost 400 million entries long. And who knows how big each entry is, even for undefs. The system is probably returning an insufficient memory error.

38293792 is only 10% as much, and seems to work ok.

wruppert

3:04 am on Apr 3, 2005 (gmt 0)

10+ Year Member



BTW, if you don't actually need all 400 million entries, you may want to use a hash.

adni18

3:43 am on Apr 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Could this possibly be related to my other entries? I have a larger array number (8929382982989282938928982) and it seems to work fine. I suppose I should use a hash.

sitz

4:52 pm on Apr 3, 2005 (gmt 0)

10+ Year Member




$ perl -le '$d[8929382982989282938928982] = 1;'
Modification of non-creatable array value attempted, subscript -2147483648 at -e line 1.

$ perl -v
This is perl, v5.8.6 built for i686-linux

FWIW. =)

(and yes. hashes are your friend in this case.)

DavidFilmer

11:12 pm on Apr 6, 2005 (gmt 0)

10+ Year Member



egads, you actually want to hold 400 million values in active RAM?

I don't know your application requirements, but this might be a good time to use a database...