I copied your code and added a } to the end of it so the sub block would be closed and it seems to work fine for me. perhaps, you are only passing one id (I tried it for 1-4), and each came back with the expected value. Only one thing will ever be returned from the
regardless of how many times an id shows up in the file, because it will only return the last value of $schoolname from your sub.