You may want to consider using on of the logging frameworks, available on CPAN, as opposed to a print based approach
Log::Log4perl, Log::Any, Log::ger are examples that support directing output of the log statements to different locations based upon a category. A category is generally a package but can be explicitly set as desired.
Here an example from the Log::ger::Manual::Tutorial::05_Category tutorial
use Log::ger::Output Composite => (
outputs => {
File => [
{
conf => {path=>'/path/app.log'},
category_level => { Foo => 'off' },
},
{
conf => {path=>'/path/foo.log'},
level => 'off',
category_level => { Foo => 'trace' },
},
],
},
);
lbe