On Fri, Feb 24, 2006 at 01:40:15PM -0700, Alan Young wrote:
> > Yes, what are the unique occurrences of text in that string?  I've run the
> > code and I'm still not exactly sure what it's supposed to do.
> >
> > use Data::Dump qw/ dump /;
> >
> > $a="abcde"x4;
> > $a=~s{((\w+?)(??{!$b{$^N}++?"(?=)":"(?!)"}))}{($1)}xg;
> > print "$a\n";
> > print dump(\%b), "\n";
> >
> > (a)(b)(c)(d)(e)(ab)(cd)(ea)(bc)(de)(abc)de
> > { a => 3, ab => 2, abc => 1, b => 2, bc => 1, c => 2, cd => 1, d => 3, de
> > => 2, e => 3, ea => 1 }
> 
> There is 1 unique occurrence of 'abc', 2 occurrences of 'ab' (not
> contained in the other occurrence of 'abc'), and 3 occurrences of 'a'
> (not contained in the other occurrences of 'abc' and 'ab').

I'm afraid I'm not getting what you mean by "unique occurrence"...  Why is
there only one unique occurrence of 'abc', when the string contains 'abc'
four times?  Why are there two unique occurrences of 'de', but only one of
'bc'?  Why are there no unique occurences at all of 'abcd'?

> I just thought it was a neat little regex that qualified as a FWP and
> pass it along to my perl monger and user groups as well.

It is a neat regex, that's why I want to understand what it's for.  :)

Ronald

Reply via email to