in reply to unix loops in perl

Your approach is failing because $i is being interpolated by Perl; the shell never sees it.

use strict; would have caught it. Well, unless your Perl script also had a variable named $i in scope. Use better var names!