Thank you for your reply. I see what you are trying to do, but I think your use of my in lexical scope around the package means ($foo, $bar, $container) are shared between all Transform objects. This will break thread safety.
Those variables are associated with a specific call to the transform() method, which is what I tried to demonstrate with my sample code. They need to remain private to that call and its delegates, but, ideally, without all the repetitive code. (Keep in mind this example is simplified... there will be more going on like alternative traversals, building transforms on top of other transforms, and so forth.)