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

Re: [FWP] 4 Consecutive Letters



On Mon, Aug 14, 2000 at 03:15:40PM -0400, Uri Guttman wrote:
> >>>>> "PS" == Peter Scott <Peter@PSDT.com> writes:
> 
> 
>   PS>         perl -ne'/(.)(??{join"",map chr ord($1)+$_,1..3})/&&print'
> 
> that seems to fail for me with 5.6. i get many words out of /usr/dict/words.
> 
> abbey
> Abernathy
> abeyance
> abeyant
> abysmal
> abyss
> 
> ...
> 
> 
> i don't think (??) is doing what you think.

In fact, it is doing exactly what he thinks; building a sub-regex and
interpolating it into the main regex.

The problem is that, with words that contain the letter 'y', the sub regex
that is built is 'z{|', which matches either 'z{' or the null string, and
so the regex matches.

One way to fix it:

perl -ne'/([a-w])(??{join"",map chr ord($1)+$_,1..3})/&&print'


Ronald

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe