Thanks Tom. It's not homework. I'm trying to parse html chess notation from a site into FEN. I labeled the blank spaces 1, now I need to add them up wherever they occur. Just for fun.

What I have tried failed miserably and I'm not sure why.

     for ($n = 8; $n <=1; $n--) {
        if ($temp =~ /(1){$n}/) {$board =~ s/(1){$n}/$n/;}
     }

My Thoughts were:
$temp holds the string I am searching through. What I thought I would get is: if $temp matches 1 {8 times} then replace 1 {8 times} with 8. It would count down. 8 1's would get an 8, 7 1's a 7 etc... Didn't work.

I'll check out what you suggested.

Cheers,
Eric


Tom Phoenix wrote:
On 12/1/07, Eric Krause <[EMAIL PROTECTED]> wrote:

I have a string like:
11111xxx11xxxx111111xx11x1xxxx

I would like to replace the 1's with the total of 1's like this:
5xxx2xxxx6xx2x1xxxx

Hmmm.... Smells like homework. What have you tried so far?

Your missing pieces of the puzzle may be: the /e flag on an s///
substitution, the length() function.

Good luck with it!

--Tom Phoenix
Stonehenge Perl Training


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to