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

Re: [FWP] 4 Consecutive Letters



On Tue, Aug 15, 2000 at 12:08:08PM +0300, Ilmari Karonen wrote:
> 
> On Mon, 14 Aug 2000, Ronald J Kimball wrote:
> > /@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.
> 
> D'oh!  Now that should've been obvious..
> 
>   perl -ne '/!@{[map+("|",a..z)[0,$_..$_+3],1..23]}/oix&&print'
> 
> And it seems the chr approach is even shorter:
> 
>   perl -ne '/!@{[map+("|",chr..chr$_+3),64..86]}/oix&&print'

And using the block form saves a few strokes:

    perl -ne '/!@{[map{;"|",chr..chr$_+3}64..86]}/oix&&print'



Abigail

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