If there is an error or die/barf in the eval, the value returned
is undef so you should check for that explicitly. Then the
$@ will have the error message from the error/die/barf.
message("got $@ from eval") unless defined(eval( {...} ));
The reason for the different approach with slice() errors
was because they are not actually detected until the
sliced value is used, not when the mapping is made.
Some syntax errors are caught initially.
--Chris
On Tue, Sep 3, 2013 at 8:07 AM, Ingo Schmid <[email protected]> wrote:
> Hi,
>
> I'm trying to catch errors on readflex using
> eval{$x=readflex($filename)} || message ("Reading $filename
> failed,mb::Error);
>
> This runs into the mutlielement-piddle-in-conditional issue since eval
> returns the piddle.
>
> I am using some dummy operation on the loaded data,
>
> eval{($x=readflex($filename))->nelem} || message ("Reading $filename
> failed,mb::Error);
>
> but it feels very ugly. Wouldn't it be better to return false or undef
> instead of dying in some way when this case occurs? I remember there was
> a recent discussion on the list, but I forgot what the result was.
>
> Just a thought, though, please ignore if you believe the current
> handling is working as wanted.
>
> Ingo
>
> _______________________________________________
> Perldl mailing list
> [email protected]
> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl