in reply to Filling an array

Your situation is a perfect example of why you should never type anything more than once for a specific amount: If you're doing it a few times now, you'll be doing it more in the future.

In this case, you just happened to be able to fill up the array with ten ones. Later on, you had to change that to 100. As a programmer, you should count on that happening and plan accordingly.

What's more, the actual number of items in the list needs to be made clear. If I'm trying to read your code, and I'm wondering how many ones there are, I have to count. That's not fun. Never mind you having to type 100 ones: What about the next person to read your code (who could be you) having to count those 100 ones.

Why are there 100 ones? I don't know, and your code doesn't tell me. Is it the number of wangos that you're processing? Then comment it:

my @arr = (1) x 10; # We can process 10 wangos.
Better yet, define a variable that tells how many wangos you can process:
my $max_wangos = 10; my @arr = (1) x $max_wangos;
Best of all, define a constant that is easily changeable AND describes what you're doing:
use strict MAX_WANGOS => 10; my @arr = (1) x MAX_WANGOS;
An excellent book that these concepts, and many many more, is Steve McConnell's excellent Code Complete. No serious programmer should be without it.

xoxo,
Andy
--
<megaphone> Throw down the gun and tiara and come out of the float! </megaphone>