in reply to Replacing string with its length in Regex

This smells a bit of being homework, but here's my answer:
sub template { return join ',', map length($_), shift =~ /(X+)/g; }

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re: Re: Replacing string with its length in Regex
by Brovnik (Hermit) on Jul 27, 2001 at 23:07 UTC
    Not homework honest.

    It is part of a Nonogram Solver/manipulator. This sub is part of the file loader. I know that nonogram solvers have been given as homework in other places, and I wrote one in C++ some time ago, but thought I would rebuild it in Perl for fun.

    This site gives more on Nonograms (also know as Paint by Numbers).
    --
    Brovnik

      Wow, so there is a name for the puzzles in picross! I take it the idea is to generate the number hints to a puzzle from an ascii bitmap?

      'The fickle fascination of and Everlasting God' - Billy Corgan, The Smashing Pumpkins