> On Thursday, April 18, 2002, at 09:04 , Allison Ogle wrote:
>
>> Hi,
>>
>> I have an array which contains letters. I need to increment these
>> letters
>> in the array one at a time. For example going from B to C. I was trying
>> something like
>>
>> $array[$x]++;
>
> did you check that you were still 'in bounds'?
>
> [jeeves:/tmp/drieux/perl] drieux% perl prin*
> Letters are now a b c d e f g h i j k l m n o p
> Letters are now b c d e f g h i j k l m n o p q
> Letters are now b c d e f g h i j k l m n o p q 1
> [jeeves:/tmp/drieux/perl] drieux%
>
> was generated using:
> #!/usr/bin/perl -w
> use strict;
> my @array = qw/ a b c d e f g h i j k l m n o p /;
>
> my $len = $#array ;
>
> print "Letters are now @array \n";
> my $x = 0;
> while( $x <= $len ) {
> $array[$x]++;
> $x++;
> }
>
> print "Letters are now @array \n";
> $array[$x]++;
>
> print "Letters are now @array \n";
>
>
> notice how when I 'increment beyond the length of the
> actual array - I start with the 'uninitialized' value
> of '0' and increment to 1......
>
> hence either your $x is out of bounds, or your @array
> was actually nulled out at some point?
ciao
drieux
---
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]