On Mon, Aug 14, 2000 at 02:48:06AM -0700, Daniel Chetlin wrote: > On the same subject, I was asked recently to think of a word which had 4 > consecutive letters (like abcd or ghij). Failing miserably to think of one, I > decided it would be good for golf. The solution I came up with is pretty long, > and I bet a better one exists, so I'm throwing out the challenge. > > perl -wne 'sub f{chr(ord($1)+pop)};print if/(.)(??{f(1)})(??{f(2)})(??{f(3)})/' > /usr/dict/2words I don't like those newfangled regex features. Why, back when I was a newbie... :D Here's my first solution: perl -ne'@a=a..z;for$i(0..22){print,last if/@{[$a[$i]..$a[$i+3]]}/x}' And a slightly shorter one: perl -ne'for$i(97..119){print,last if/@{[map chr,$i..$i+3]}/x}' > BTW, no words that fit that pattern are in the standard Linux > /usr/dict/words -- I had to use a different word list that I found > elsewhere. But reasonably common words that fit do exist. Ah, I've found a few. Ronald ==== Want to unsubscribe from Fun With Perl? Well, if you insist... ==== Send email to <fwp-request@technofile.org> with message _body_ ==== unsubscribe