[Omaha.pm] Substitution loop

Rob Townley rob.townley at gmail.com
Tue Jul 31 13:47:19 PDT 2007


On 7/31/07, Dan Linder <dan at linder.org> wrote:
>
> Jay Hannah wrote:
> > But what is a fatal "Substitution loop" error from Perl?
> >
> > I've never seen that one before. It disappeared without me changing
> > anything and I can't make it happen again.
> >
> > Probably user error.   :)
> >
> From "http://search.cpan.org/~nwclark/perl-5.8.8/pod/perldiag.pod":
> Substitution loop : (P) The substitution was looping infinitely.
> (Obviously, a substitution shouldn't iterate more times than there are
> characters of input, which is what happened.) See the discussion of
> substitution in "Quote and Quote-like Operators" in perlop.
>
> I can't see how the simple "$d1=~s/[^\d]//g;" could cause the loop as
> described above -- what happens if $d1 was all numbers - if there is a
> bug in the length check, then it could count X characters but try to run
> X+1 times and get that error...  (Just a shot in the dark, though.)
>
> Do you have a way of catching the error next time and logging the
> initial contents of $d1?
>
> Dan
>
> --
> - - - -
> "Wait for that wisest of all counselors, time." -- Pericles "I do not
> fear computers, I fear the lack of them." -- Isaac Asimov
>
>
> _______________________________________________
> Omaha-pm mailing list
> Omaha-pm at pm.org
> http://mail.pm.org/mailman/listinfo/omaha-pm
>


i bet it depends on the content of the string input - if you have all
digits, i bet you do not get an error.  Doesn't it mean that you putting
into the s string a character that is not a number, so it is replaced again,
then removed again, replaced ad infinitum.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/omaha-pm/attachments/20070731/e511715d/attachment.html 


More information about the Omaha-pm mailing list