On Mon, Aug 14, 2000 at 11:29:04AM -0500, Tim Ayers wrote: > >>>>> "R" == Ronald J Kimball <rjk@linguist.dartmouth.edu> writes: > R> Here's my first solution: > R> perl -ne'@a=a..z;for$i(0..22){print,last if/@{[$a[$i]..$a[$i+3]]}/x}' > > R> And a slightly shorter one: > R> perl -ne'for$i(97..119){print,last if/@{[map chr,$i..$i+3]}/x}' > > Ronald's first solution seems to be able to be modified to be shorter: > > perl -ne'@a=a..z;for$i(0..22){print,last if/@a[$i..$i+3]/x}' I can't believe I didn't see that. > At least this appears to work for me in 5.005_03 and 5.6.0. > > Ronald, would you explain what the /x modifier is doing here? It > doesn't work without it, but I thought /x was just to allow > expressive/expanded regexes. I have a hypothesis, but I personally > couldn't find anything in L<perlre> or Camel v3. Thank you. /@a[$i..$i+3]/ interpolates @a[$i..$i+3] as join($", @a[$i..$i+3]), resulting in a regex like /a b c d/. But we need a regex like /abcd/. One solution would be to set $" to '', but a shorter solution is to use /x, which tells Perl to ignore the whitespace in the regex. Ronald ==== Want to unsubscribe from Fun With Perl? Well, if you insist... ==== Send email to <fwp-request@technofile.org> with message _body_ ==== unsubscribe