in reply to Array ref error!

To expound on what Corion said, the line $sql->[0]{user} is short hand for:
  1. Dereference the scalar value in $sql as an array reference.
  2. Get the first value in the array
  3. Dereference that as a hash reference.
  4. Get the hash entry for user

Since the error says the interpreter expects an ARRAY ref, that means the error is in step 1. Examine the code around the line you've given us to determine what you've assigned to $sql. If this is unclear, see perlreftut for an broader introduction to references.