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

------


In reply to Re: PERL exit code 255 by Anonymous Monk
in thread PERL exit code 255 by mcintst

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.