develooper Front page | perl.perl5.porters | Postings from August 2012

caller() not useful during sub DESTROY

Thread Next
Paul LeoNerd Evans
August 16, 2012 13:13
caller() not useful during sub DESTROY
Message ID:
Consider the following program:


  use strict;
  use warnings;

  package WhereDidIGo;

  sub DESTROY {
     print STDERR "DESTROYed at ", join(", ", (caller)[0,1,2] ), "\n";

     my $thing = bless [], "WhereDidIGo";
     undef $thing;                                  #### this is line 14

When run this outputs:

  $ perl 
  DESTROYed at main,, 0

I had been expecting the output:

  DESTROYed at WhereDidIGo,, 14

I have an object (CPS::Future) that represents a task-in-progress. I was
hoping to be able to print a warning message for debugging purposes, if
such an object is dropped before it completes.

Paul "LeoNerd" Evans
ICQ# 4135350       |  Registered Linux# 179460

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About