develooper Front page | perl.beginners | Postings from October 2009

Re: eval and next

Thread Previous
From:
Jenda Krynicky
Date:
October 7, 2009 04:20
Subject:
Re: eval and next
Message ID:
4ACC958E.22258.823F792@Jenda.Krynicky.cz
Date sent:      	Tue, 06 Oct 2009 15:45:44 +0200
From:           	Alexander Koenig <Alexander.Koenig@mpi.nl>
To:             	beginners <beginners@perl.org>
Subject:        	eval and next

> Hi all,
> 
> I have a Perl program where I use eval to catch errors. As they are Java
> errors (via Inline::Java) I want my program to continue and just log the
> errors somewhere.
> 
> My problem with this is, that I use the eval within a loop and I also
> use next in this loop to ignore some special cases. But now, whenever
> the next is triggered I get a warning like this:
> 
> Exiting eval via next at ad_hoc_stats.pl line 204, <GEN6> line 5421.
> 
> Googling the message I found this thread on Perlmonks
> http://www.perlmonks.org/?node_id=104789
> 
> But that does not seem to be about the same problem. I know that next is
> executed for the enclosing for loop and not for the eval block. That is
> how I want it. I tried naming the for loop to show perl that I know what
> I'm doing but the warning persists.
> 
> Is there some recommended way of doing this, so that I won't get a
> warning every time the next is triggered?

I think it's easiest to disable that particular warning for that 
block.

 ...
 eval {
  no warnings 'exiting';
  ...

Jenda
===== Jenda@Krynicky.cz === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
	-- Terry Pratchett in Sourcery


Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About