jepri has asked for the wisdom of the Perl Monks concerning the following question:

I can't figure what the problem is here. I'm using this bit of code: P>
print STDERR "Now ready to insert new selections: "; { foreach (@keywords){ if (/group\_|field\_/) { print STDERR $_; reset; print STDERR "Regex reset\n"; /(.*)\_(\d*)/;
which results in:

Now ready to insert new selections: group_1[Mon May 7 19:27:08 2001] +[notice] child pid 5876 exit signal Segmentation fault (11)

If I comment out the reset, the program runs fine (apart from the few cases where the next regex fails to match and I get garbage being passed). This piece of code is in multiple complicated whiles and fors with lexical variables all over the the place.

Am I doing something obviously wrong, or is this just a weird thing that happens sometimes?

Running under the version of perl listed below, Apache+mod_perl.

perl5 (5.0 patchlevel 5 subversion 3)

Thanks in advance,

____________________
Jeremy
I didn't believe in evil until I dated it.

Replies are listed 'Best First'.
Re: 'reset' causes segfault
by busunsl (Vicar) on May 07, 2001 at 13:50 UTC
    Your bit of code works fine for me, but this is perl 5.6.0 and no mod_perl.

    But I don't understand why you need reset.
    You are not using a ?? pattern, so reset will be useless.

      Sigh. I was doing something boneheaded after all. Thanks for pointing it out ++

      I seem to have picked up the idea from somewhere that I should clear previous matches with reset. I suspect that I was thinking reset '1-9' but that doesn't do it either.

      ____________________
      Jeremy
      I didn't believe in evil until I dated it.