Hi Marius!
On Wed, 19 Dec 2001, Marius Stan wrote:
> Salut,
> Am un script PERL in care vreau sa interceptez eu erorile intr-o subrutina proprie.
> Cu alte cuvinte, vreau sa execut o subrutina inainte sa moara scriptul cu eroare.
> Cum fac asta ?
>
> 10x,
> Marius
Daca scriptul moare din cauza lui `die()' atunci :
(vezi `perldoc -f die') :
``
You can arrange for a callback to be run just
before the `die' does its deed, by setting the
`$SIG{__DIE__}' hook. The associated handler will
be called with the error text and can change the
error message, if it sees fit, by calling `die'
again. See the section on "$SIG{expr}" in the
perlvar manpage for details on setting `%SIG'
entries, and the section on "eval BLOCK" for some
examples. Although this feature was meant to be
run only right before your program was to exit,
this is not currently the case--the
`$SIG{__DIE__}' hook is currently called even
inside eval()ed blocks/strings! If one wants the
hook to do nothing in such situations, put
die @_ if $^S;
as the first line of the handler (see the section
on "$^S" in the perlvar manpage). Because this
promotes strange action at a distance, this
counterintuitive behavior may be fixed in a future
release.
''
Altfel, ai putea sa rulezi scriptul intr`un `eval { ... };' mare
si sa prinzi erorile de `die()' cu
if ($@) { &trateaza_eroare($@); }
Sper ca asta vrei ...
Bogdan
---
Send e-mail to '[EMAIL PROTECTED]' with 'unsubscribe rlug' to
unsubscribe from this list.