in reply to Fetching DB using a While loop.

I want to use a "WHILE" loop instead of a "FOR" loop
my $i = 0; while ($i < @$allnames) { .... $i++; }

instead of

for (my $i = 0; $i < @$allnames; $i++) { .... }

But why...?  — Maybe you rather want something like

for my $elem (@$allnames) { my $allname = $elem->{name} || ''; my $alladdress = $elem->{address} || ''; ... }