in reply to Avoiding circular references
I'm not really sure what the question is, but if your coderef doesn't need access to $self and only needs access to $dbh, then yes, it's a good idea for it to avoid closing over $self.
The case where you'd want it to close over $self instead of $dbh would be if there was something like a $self->switch_database method that set a new database to connect to, and you wanted your coderef to be aware of the switch instead of continuing to point to the old database.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Avoiding circular references
by ikegami (Patriarch) on Dec 06, 2019 at 22:14 UTC | |
by ikegami (Patriarch) on Dec 06, 2019 at 22:27 UTC | |
by ikegami (Patriarch) on Dec 06, 2019 at 22:37 UTC | |
|
Re^2: Avoiding circular references
by frazap (Monk) on Dec 06, 2019 at 13:54 UTC | |
by tobyink (Canon) on Dec 06, 2019 at 14:48 UTC | |
by frazap (Monk) on Dec 06, 2019 at 15:16 UTC | |
by haj (Vicar) on Dec 06, 2019 at 19:27 UTC |