in reply to Running a sub before a script exits?

I am using the below code in a script and cannot figure out how to automatically run the sub save_config before the script exits.

END { save_config() }

Ignore that. rattusillegitimus has a better answer below.

Replies are listed 'Best First'.
Re: Re: Running a sub before a script exits?
by Anonymous Monk on Aug 25, 2002 at 04:49 UTC
    Not necessarily.

    In most versions of Perl if your variable is pointed at by a global, it is DESTROYed haphazardly in global destruction. Therefore you may not have a config left to save when DESTROY is called. But you always should in END.