http://qs1969.pair.com?node_id=692295


in reply to Re: Run before exit
in thread Run before exit

Wouldn't that be executed as well with die()?

--
b10m

Replies are listed 'Best First'.
Re^2: Run before exit
by moritz (Cardinal) on Jun 16, 2008 at 16:14 UTC
    Yes. I didn't parse the "only" in the original question correctly. If it should really only be triggered by exit, it might be useful to override it (CORE::exit IIRC).
      (CORE::exit IIRC)

      Use CORE::GLOBAL::exit() to override — CORE::exit() is the original exit builtin that you'd typically call from within your redefined exit routine...

      Update: an example:

      #!/usr/bin/perl BEGIN { *CORE::GLOBAL::exit = sub (;$) { print STDERR "in overridden exit(): @_\n"; CORE::exit(88); }; } exit 99;