This looks hairy for several reasons.
- diff $i $j doesn't compare the strings $i and $j, but interprets them as file names. I see no indication in your textual description that that's the goal. If you just want to compare strings for equality, use $i eq $j in Perl.
- `program > /dev/null` doesn't make any sense to me. First throw away the output, then capture it, then discard it again by putting it in void context...
- Since each `...` line starts its own shell, the exit status from diff command won't be available in `$?`.
Perl 6 - links to (nearly) everything that is Perl 6.