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


in reply to Passing a variable recursively

OO noob here, so I'm just asking without having tested this yet, but --

Wouldn't another approach be to pass the logger object to the module if you wish it to use that logger object instance?

something like:

# calling program stuff my $loggerHandle = new myLogger(); my $workerHandle = new myWorker(); my $returnValue = $workerHandle($loggerHandle, $Parameter, $Option, $E +tc);

You achieve the intended result, which is a lot like Global State, but not with a Global State implementation. You tell the subordinate method which logger to use, and its logging behavior is driven by its previously-established logging level attribute.

Or am I out in left field here, and worse, the game is soccer?