Home: Perl Programming Help: Advanced:
Display Array Content error............



webhay
Novice

Jan 2, 2001, 6:32 AM


Views: 1504
Display Array Content error............

I want to Display Array Content Like This But Is Not Working...

For($i=10; $i<@array; $i++)
{
print Something;

}

Please Helpe; :-)



Jasmine
Administrator / Moderator

Jan 2, 2001, 8:53 AM


Views: 1503
Re: Display Array Content error............

The question is what is in @array when you run this snippet.

Basically you're saying "i is equal to 1. While i is less than then the total number of elements in @array, increment i and print something".

If you're not starting out with at least 11 elements in @array, nothing will be printed.


Code
@array = (1 .. 11); 

for($i=10; $i<@array; $i++)
{
print "$i\n";

}

The above prints out the number 10 only.