Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: PERL exit code 255

by Anonymous Monk
on Mar 07, 2018 at 20:48 UTC ( #1210477=note: print w/replies, xml ) Need Help??


in reply to PERL exit code 255

You have an example of capturing the pseudo-signal __DIE__

See perldoc -f die, to see the posible exit codes (one of them is 255)

-------

oscar@toreyes-i7:~/WIP/perl/gestion_DIE$ cat prueba.pl use diagnostics; use strict; sub mensaje() { print "OJO !!!! Este script se ha muerto por la ejecuc +ión de die()\n"; } # Instalar manejador en caso de ejecuarse un die() $SIG{__DIE__} = \&mensaje; my $refFake = 'pepe'; print $refFake->{'lolo'}; # Aqui se genera el error print "Me moriré antes de mostrar esta linea\n"; oscar@toreyes-i7:~/WIP/perl/gestion_DIE$ perl prueba.pl OJO !!!! Este script se ha muerto por la ejecución de die() Can't use string ("pepe") as a HASH ref while "strict refs" in use at +prueba.pl line 10. oscar@toreyes-i7:~/WIP/perl/gestion_DIE$ echo $? 255

-------

Another example:

oscar@toreyes-i7:~/WIP/perl/gestion_DIE$ cat prueba2.pl use diagnostics; use strict; use Data::Dumper; sub mensaje() { print "OJO !!!! Este script se ha muerto por la ejecuc +ión de die()\n"; } sub handler { # 1st argument is signal name # En caso de una "unhandled excepcion" como la +generada # por die(), @_ parece que es el mensaje de err +or en vez # del identificador de una señal real. my($sig) = @_; print "Dumper(\$sig): ", Dumper($sig); if ($sig) { print "sig:", $sig, "\n"; print "Caught a SIG$sig--shutting down\n"; } else { print "sig no tiene un valor de señal\n"; } ## exit(0); } # Instalar manejador en caso de ejecutarse un die() # $SIG{__DIE__} = \&mensaje; $SIG{__DIE__} = \&handler; my $refFake = 'pepe'; print $refFake->{'lolo'}; # Aqui se genera el error print "Me moriré antes de mostrar esta linea\n"; oscar@toreyes-i7:~/WIP/perl/gestion_DIE$ echo $? 255

------

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1210477]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2018-07-23 10:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (462 votes). Check out past polls.

    Notices?