http://www.perlmonks.org?node_id=262784


in reply to Substitution operator troubles

As far as I can tell you are only missing the global flag. That is:
$tool =~ s/<infile>/$file/;
Should be:
$tool =~ s/<infile>/$file/g;