John Deighan wrote:The problem with trying to use goto, or a return, or setting a global variable is that they don't work well in a function that's being called by the code that contains the eval. 'return' won't work because it will simply return from the function that was called.
No it doesn't. Have you even tried it?
You are right that 'return' will return from either 1) the enclosing eval block or 2) the enclosing function, whichever is "closer". However you misunderstood what I was saying. My structure is more like:
eval {
...some code
func();
};
if ($@) {
...handle if an error occurred
}# --- this possibly in another file
sub func {... so something return; }
Where the 'return' is, in the function func(), I want to proceed to immediately after the original eval block. The only way I know to do that is with a die(), though in this case, there is no error, so I was hoping there was an equivalent to die() that didn't set [EMAIL PROTECTED] My current solution is to replace the 'return' above with a
die('Status: OK\n");and then to replace the
if ($@)
with
if ($@ && ($@ ne 'Status: OK\n'))#!/usr/bin/perl sub foo {
my $ret = eval { return 1; };
print "ret = $ret$/";
return 2; }
print "Foo returns ", foo(), $/; __END__ output is: ret = 1 Foo returns 2
Rhesa
Scanned for Spam and Viruses.
_______________________________________________ Perl-Win32-Users mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
