http://qs321.pair.com?node_id=1227150


in reply to Grep Pattern

You could pre-program your pattern, which imho is elegant and transparent and easily adaptable to more complex situations.

@pat = ( 0, 1, 1, 0 ); $i = 0; @result = grep { $pat[ $i++ % 4 ] } 0..12;

I guess you could also replace "4" with "@pat" to make it even more general.