1 a) nested linear scans b) use a hash 2) @array[0..$#array] = @array[reverse 0..$#array]; That's *not* a built-in array-reversal method. 3) Modularize into the three primary layers: requests, db queries, output templates.