[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Garbage collection



On 19991121 1558, Mark Pease wrote:

>Not "sub END {}"
>
>END {
>}

perlmod says "The sub is optional for these routines."
                         ^^^^^^^^

Regardless, it makes no difference in the result whether I use sub END {} 
or just END {}.  In *neither* case does the code block get executed.


>This is the "END block", not a subroutine, and is special in that it is
>a "destructor" it will be executed as late a possible (that is, when
>Perl is exiting.)

perlmod again: "An END subroutine is executed as late as possible,
                       ^^^^^^^^^^
that is, when the interpreter is being exited, even if it is exiting as a 
result of a die() function.  (But not if it's is being blown out of the 
water by a signal--you have to trap that yourself (if you can).)"


...which leads me back to thinking that I have to catch the 'quit' apple 
event by extending the event handler (assuming Unix signals and MacOS 
AppleEvents are treated the same).

Once again, I'm just trying to get something simple working, like this:

---
#!perl -w

END
{
  open LOG, ">>LOG.TXT";
  print LOG "END executed!\n";
  close LOG;
}

print "Enter a command: ";
$command = <STDIN>;
print $command;
---

Run the script.  Instead of entering something at the prompt, select 
"Quit" from the the "File" menu.  The END subroutine does *NOT* get 
executed (or, at least, nothing is written to the log file), and the 
following is reported to STDERR:

# Callback called exit.
# END failed--cleanup aborted.

Any more ideas?

Henry.

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org