Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Below is the offending code:

if ( -e "$ENV{HOME}/$HISTFILE" ) { print "YEP! It exists\n"; $href = retrieve( "$ENV{HOME}/$HISTFILE" ); } else { croak "I cant find $HISTFILE in your HOME dir "; }

Every time I run my program I get the error:
"Uncaught exception from user code"
What is an "uncaught exception"? How do I tell perl not to print this text?

Replies are listed 'Best First'.
Re: A clean die/croak
by LanX (Saint) on Feb 25, 2022 at 19:37 UTC
    > Every time I run my program I get the error: "Uncaught exception from user code"

    Because diagnostics is (secretly) used by you!

    d:\tmp>perl -MCarp -Mdiagnostics -e"croak 'bla'" Uncaught exception from user code: bla at -e line 1. d:\tmp>

    see also this SO discussion which I found by simply googling for you...

    update

    > How do I tell perl not to print this text?

    either don't use diagnostics at all ...

    ... or disable diagnostics before dieing

    d:\tmp>perl -Mdiagnostics -e"disable diagnostics; die 'bla'" bla at -e line 1. d:\tmp>

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

      I remember the "use diagnistics" line. I had no idea there is a connection. Thanks.