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

Re: [FWP] 4 Consecutive Letters



>>>>> "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}'

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.

Hope you have a very nice day, :-)
Tim Ayers (tayers@bridge.com)


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