1perl;
2  use strict;
3  use Time::HiRes qw(sleep);
4  my $search_count= $ENV{'SEARCH_COUNT'} or die "SEARCH_COUNT not set";
5  my $search_file= $ENV{'SEARCH_FILE'} or die "SEARCH_FILE not set";
6  my $wait_counter= 100; # 10 seconds
7  while (1)
8  {
9    my $cnt= 0;
10    open(FILE, $search_file) or die("Unable to open '$search_file': $!\n");
11    $cnt++ while (<FILE>);
12    close(FILE);
13    last if ($cnt == $search_count);
14    $wait_counter-- or
15      die "Timeout waiting for $search_count lines in $search_file\n";
16    sleep(0.1);
17  }
18EOF
19