in reply to special characters storage in perl

You use the variable $index in two loops, so as soon as the first if-condition matches, the inner loop also exhausts the outer loop.

Instead of iterating over the indexes you can simply iterate over the array elements directly, for my $item (@records) { ... } and then use $item where you used to use $records[$index].

Also you should use strict; use warnings; and declare your variables.

Replies are listed 'Best First'.
Re^2: special characters storage in perl
by dreadpiratepeter (Priest) on Aug 05, 2009 at 13:29 UTC
    look at the return in the inner loop. I think the logic is what he intended. I theorize that his data looks like:
    username row
    num questions row
    username row
    num questions row
    username row 
    num questions row
    ...
    
    and that he is calling the function multiple times to get all his users (although I have no idea how he knows when to stop). he probably (shutter) has a loop around the function that tests $index < @records.


    -pete
    "Worry is like a rocking chair. It gives you something to do, but it doesn't get you anywhere."