in reply to Re: Style and Preference on Loops
in thread Style and Preference on Loops

for my $idx ( 0..@$mysql ) {
Of course, that should read:
for my $idx ( 0..@$mysql-1 ) {

Replies are listed 'Best First'.
Re^3: Style and Preference on Loops
by jwkrahn (Abbot) on Aug 12, 2011 at 23:01 UTC

    No, it should read:

    for my $idx ( 0..$#$mysql ) {

      Though my version was not incorrect, I agree this is probably a better alternative here.

      Generally, I dislike the ungainly $#some_array syntax and it's rarely needed. For example:

      $some_array[$#some_array]
      is better written as:
      $some_array[-1]
      because, apart from the unpleasant-to-read $#some_array, the second form avoids the duplication of some_array.

Re^3: Style and Preference on Loops
by TomDLux (Vicar) on Aug 15, 2011 at 13:50 UTC

    Thank you.

    As Occam said: Entia non sunt multiplicanda praeter necessitatem.