[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Omaha.pm] Substitution loop




On Jul 31, 2007, at 2:17 PM, Jay Hannah wrote:

Substitution loop at CommonShare.pm line 65.

line 65 looks harmless enough:

  $d1=~s/[^\d]//g;

Anyone seen that error before?

Diving....  :)

Sure. The /g is a modifier saying "do this on everything throughout the string". In this case, it's removing every non-digit character from the string.

It would be even better to have it as

   $dl =~ s/[^\d]+//g;

That way if you have a string of ten non-digits, they'll all get removed at once, rather via ten checks.

You can also use the tr/// operator for this sort of thing, if you want.

xoxo,
Andy

--
Andy Lester => andy@petdance.com => www.petdance.com => AIM:petdance