in reply to system commands aren't working as a loop.

Maybe read up on what perlop says about qw, or just print out @cmd before running it.

Also try:

perl -le "print qq([$_]\n) for qw($foo $bar $baz);"

Alternatively, try taking away the loop and just using the first entry from @files.