Re: [Spoiler] QotW 23

Rod Adams <[email protected]>
Newsgroups gmane.comp.lang.perl.qotw.discuss
Message-ID <[email protected]>
Daniel Martin wrote:

>Rod Adams <[email protected]> writes:
>
>>sub Insert {
>>    
>>
>Anyway, I thought I'd let you know that I've discovered a very simple
>way to avoid the necessity of a "seen" hash. 
>

I _knew_ there had to be a way to avoid it, and it was frustrating me 
that I didn't see it. Good job finding it. And it's so simple..... But 
not obvious without doing the detailed trace that you did.

btw,
change

   my $limit = index $item, ')';

to

   my $limit = index $item, ')';
   $limit = 0 if $limit < 0;

and the seed from '()' to '', and you should be able to handle n=0.
Oh, it looks like you have to move the print test to the start of the while loop.


--- Rod
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.