Use DEFINE: %{res} = ... instead of $(cat ...). Rewrite one use of a subshell to write to a temporary file instead.