summaryrefslogtreecommitdiff
path: root/nocompile/bin/XuntilY
blob: f6cc672c99440c5960a864e66fba07ceed072bf4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/pkg/bin/perl
$r=$ARGV[0];
$s=$ARGV[1];
$m=0;
$count=$ARGV[2]?$ARGV[2]:1;
for(;$l=<stdin> and $count > 0;) {
 if($m == 0) {
  if($l =~ $r) {
   $m=1;
   print $l;
   next;
 }}
 if($m == 1) {
  print $l;
  if($l =~ $s) {
   $m=0;
   $count--;
}}}