Home : Dokumentation : 1.3.6 Dokumentation : Tips & Tricks
Google Web perl.apache.org

 
Home
 
Features
 
Einführung
 
Dokumentation
 
README
 
README.v2
 
Konfiguration
 
Embperl
 
Embperl::Object
 
Embperl::Form::Validate
 
Embperl::Syntax
 
Embperl::Recipe
 
Embperl::Mail
 
1.3.6 Dokumentation
 
HTML::Embperl
 
HTML::EmbperlObject
 
HTML::Embperl::Mail
 
HTML::Embperl::Session
 
Tips & Tricks
 
FAQ
 
DBIx::Recordset
 
Installation
 
Download
 
Support
 
Änderungen
 
Wiki
 
Weitere Infos
 
Hinzufügen Infos
 
Login

    Stable 2.4.0
    Beta 2.5.0_3
Unterstützen Sie Embperl! Mehr...
Handling Exits
[ << Prev: Handling Queries in DBI ] [ Content ] [ Next: Handling Errors >> ]

You will often find that you want to terminate a page before the end. This doesn't necessarily indicate an error condition; it can be just that you've done all you want to do. When you do this, it is good to first clean up, otherwise you can get annoying warnings showing up in your error logs.

I use the following framework. /cleanup.html is Executed from /base.html, and it is the last thing that is done. It calls the cleanup() function in the /subs.html file:

/cleanup.html

[- $subs->cleanup (); -]

/subs.html

[! sub cleanup { while (($name, $query) = each (%domain::query)) { $query->finish(); } $domain::dbh->disconnect(); }

sub clean_exit { cleanup(); exit(); } !]

Now, whenever I want to exit prematurely, I use a call to $subs->clean_exit() rather than just exit(). This makes sure that the queries and database connections are shut down nicely.


[ << Prev: Handling Queries in DBI ] [ Content ] [ Next: Handling Errors >> ]

© 1997-2012 Gerald Richter / ecos gmbh