in reply to Handling errors on perl

use a block eval:

eval { push @tbl, [ @$_ ] for $table->rows } or warn " ERRORE $hname $chin ";

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Replies are listed 'Best First'.
Re^2: Handling errors on perl
by limner (Novice) on Aug 19, 2018 at 16:28 UTC
    Hi
    thank you for your answer.

    i was able to do the following, and worked very well:

    eval { push @tbl, [ @$_ ] for $table->rows };<br> if ($@) {<br> my $error = $@; <br> warn " Custom error type 1 = no problem ";<br> }


    this piece of code is inside a perl that is called from another perl so i use "my $error" cause the problem of global $@ and worked as i wanted.
    Now the small problem left is the following, the message i receive when the error raise is the following:

    Custom error type 1 = no problem  at perl_parse_v3.pl line 88.

    i simply would like to avoid "at perl_parse_v3.pl line 88." because i not necessary cause i perfecly know that only one cause can raise the error.
    how can that be done?
      Put a newline \n at the end of your warn text.

      It's described in the second phrase of the documentation.

      "If the last element of LIST does not end in a newline, it appends the same file/line number text as die does."

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery FootballPerl is like chess, only without the dice