In addition, your script won't work as expected if any filename contains any special character (such as a space). You should get in the habit of always enclosing variable references in double quotes. Try this:

That will throw an error, unless $i happens to hold a command name.
–
glenn jackmanApr 15 '11 at 10:32

Yes, it's buggy code in ways beyond the double quotes. I see now that the original reply has been edited to include backticks. So, now I have a better idea of what the OP wanted. Without those backticks, the code is incomprehensible, at least to me. I've edited my answer.
–
Scott SeveranceApr 15 '11 at 13:07