in reply to Re^4: (in cleanup) Can't call method "close" on an undefined value at somePerlModule.pm line number.
in thread (in cleanup) Can't call method "close" on an undefined value at somePerlModule.pm line number.

If for example, your class uses a database, the destructor would be a good place to close the connection.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked
  • Comment on Re^5: (in cleanup) Can't call method "close" on an undefined value at somePerlModule.pm line number.

Replies are listed 'Best First'.
Re^6: (in cleanup) Can't call method "close" on an undefined value at somePerlModule.pm line number.
by Anonymous Monk on Feb 01, 2015 at 20:06 UTC

    If for example, your class uses a database, the destructor would be a good place to close the connection.

    Yup, but DBI connections already come with a destructor that closes the connection, so :)

    Another use scenario is to break circular references, but those are easily avoided with https://metacpan.org/pod/Scalar::Util#weaken

    Yup, in perl, I've rarely written a destructor

      Yup, but DBI connections already come with a destructor that closes the connection,

      "DB" does not necessarily imply "DBI".


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
      In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked