Eric Walker wrote:
> Hello all
> While traversing a loop across and array, how can I access array
> positions further down the array, like say if I am on a loop looking
> at position 23, how can I check the value of say position 24 or 32
> while my loop counter is on position 23.
> 
> Thanks
> perl knucklehead

        To do that you might want to use: for and check on whether an item is defined 
or not. Then you know the id you are on and can add or subtract depending on what you 
need.

So for a starter, you could try:

        for(my $MyId=0;$MyId<scalar(@MyArray);$MyId++) {
            next if ( ! defined $MyArray[$MyId] );
            my $MyCheckId = $MyId + 2;  # looking at item two above
            if ( $MyArray[$Myid] > $MyArray[$MyCheckid] ) {
                 # do something
             }else {
                 # do something else
             }
       }

I think you see what I mean.

Wags ;)


**********************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
****************************************************************


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to