Pregunta

I'm suffering an annoying problem when trying to die from within an eval.

The code is as follows;

$status = eval { $self->$func( @{$y->{args}} ); };

in this case $self->$func points to a handler that detaches to a certain page on error like this:

sub detach
{
    my $self   = shift;
    my $url    = shift;
    my @params = @_;

    if( $url !~ /^\// )
    {
        $url = '/' . $self->namespace . '/' . $url;
    }
    $url =~ s/\sat.*$//;
    print STDERR $self->uri . ": Detaching to " . $url . "\n";

    die "REDIR:$url";
}

this should place "REDIR:$url" into $@ so it's available when the eval exits.

However, instead Carp.pm dies, I assume somewhere in the internals of die with

Bizarre copy of ARRAY in sassign at /usr/share/perl/5.10/Carp.pm line 182

Looking around there is some suggestion that there is a bug deep in perl relating to the stack during die (e.g. http://code.activestate.com/lists/perl5-porters/149248/), however I'm afraid that at this point I'm at the limit of my knowledge of perl and I'm not sure if this is relevant, or what to do about it if it is. :(

Does anyone know if there is a way around this problem or another way to pass an error string back from the eval, or if I'm reading this incorrectly?

¿Fue útil?

Solución 2

This turned out to be a problem with the version of Perl I was using. Upgrading to 5.16.1 resolved the problem.

Otros consejos

This sounds to me like #52610. Are you using any module that hooks into the debugger that could be the culprit?

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top