in reply to Functions in substitutions (s///) and Perl 5.8.

That panic error sure sounds like a perl bug; I couldn't reproduce it in 5.8.0 in a quick test. Can you provide a very short but complete example that exhibits the error?

Off the top of my head, you might try introducing some interpolation to see if that would make a difference:

s/\[\[(\w+)\]\]/$helper->("$1")/eg;
or maybe:
s/\[\[(\w+)\]\]/"@{[$helper->($1)]}"/eg;
or even an explicit copy:
s/\[\[(\w+)\]\]/my $match = $1; $helper->($match)/eg;
Functionally, these should be no different, but if this is an internal perl bug, these alternatives may take a different code path and might not trip over the bug... (If you're lucky!)

Replies are listed 'Best First'.
Re: Re: Functions in substitutions (s///) and Perl 5.8.
by teichman (Novice) on Oct 25, 2002 at 15:11 UTC

    You're right - a simple test case doesn't have any problems. It turns out that our (I'm working with v_thunder on this project) helper function was trampling over $_, which caused the failed assertion only in combination with some other buggy code.

    Rewriting the helper to use a different local variable makes the original code work as expected.

    I'm having trouble producing a simple case that shows the problem. I think we just happened to hit a case where buggy code happened to work on earlier perls, but doesn't in 5.8. :)