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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Grep Pattern
by ikegami (Patriarch) on Dec 12, 2018 at 16:19 UTC | |
by LanX (Saint) on Dec 12, 2018 at 16:43 UTC | |
by hdb (Monsignor) on Dec 13, 2018 at 08:29 UTC | |
by ikegami (Patriarch) on Dec 13, 2018 at 18:25 UTC | |
by LanX (Saint) on Dec 14, 2018 at 12:29 UTC | |
by ikegami (Patriarch) on Dec 14, 2018 at 17:06 UTC | |
| |
by Aldebaran (Curate) on Dec 15, 2018 at 00:38 UTC | |
by LanX (Saint) on Dec 15, 2018 at 01:36 UTC | |
by ikegami (Patriarch) on Dec 15, 2018 at 15:48 UTC |
In Section
Seekers of Perl Wisdom