or download this
foreach my $infile (@files) {
print $infile . "\n";
...
system "$handbrake -i '$infile' -o '$outfile' --preset=$preset"; #
+ without escaped spaces
#system "$handbrake -i $infile' -o $outfile --preset=$preset"; # w
+ith escaped spaces
}