my $logger = sub { $log->message(@_); } # now you can call $logger like this: $logger->('This is a logging message'); # or like that: &$logger('This is a logging message');
Don't know if that answers your question, though.
Update: on second reading I think your problem is a different one: you want to print $log. But what do you want the output to be? An object doesn't have a nice default string representation.
In reply to Re: how to pass object to a subroutine
by moritz
in thread how to pass object to a subroutine
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |