in reply to Substitution operator troubles

You're changing the array elements in-place. Once you've substituted away <infile>, it's gone for good. You could instead work on copies of the array elements:

foreach my $tool (@$tools) { my $edit_tool = $tool; $edit_tool =~ s/<infile>/$file/ or next; }