Brian <> wrote:
> Shouldn't -
> my @a;
> my $y = 1;
> push (@a, $y);
> foreach my $x (0..$#a) {
> print "array = @a\n";
> $y++;
> push (@a, $y);
> }
> result in an endless loop? And if not (I can't get it to) how do I
> create an endless loop like that above?
Well, by using $#a, you're giving a specific set of indexes (0 and
whatever $#a is) to operate on.
If you want to operate on an array, operate on an array. This is how I
would have done it in the first place. Don't mess with indexes if you
don't want to mess with indexes...
my $y = 1;
my @a = ($y);
foreach my $x (@a)
{
print "array = @a\n";
print "index variable= $x\n";
$y++;
push (@a, $y);
}
--
Darren Dunham
Unix System Administrator Taos - The SysAdmin Company
Got some Dr Pepper? San Francisco, CA bay area
< This line left intentionally blank to confuse you. >