http://www.perlmonks.org?node_id=736227


in reply to eval and return values

I'd write that as:
my $foo; eval {$foo = bar->something(); 1} or die "eval failed ($@)"; $foo;
First, I don't 'my' $foo inside the block. Second, an eval may fail, yet leave $@ false (because of 'end of scope' effects). So you should make sure that on success, the eval returns a defined value, and check the return value of the eval.