in reply to grep & timesearch

It's not clear what you mean by "let's say I ran the timesearch script with the grep script inside". But you have two conditions here: the regex match and the time range. You can just combine them:

if (($2 ge $min) && ($2 le $max) && /$key/) { push(@{$mylist{$2}}, $_); }

Replies are listed 'Best First'.
Re: Re: grep & timesearch
by Anonymous Monk on Jul 12, 2001 at 19:51 UTC
    Yes that would work it would just be like using perls grep function However I tried what you suggested and even put $key in the split function line of the timesearch script and it won't find what I search on and I know the script should find data because I verified the data to match. I even expanded my pattern match line so I could $key what field to look in and what it should be equal to but that didn't work either. For example here's what the lines of code I changed to try to make it work. Of course with $range equaling <STDIN>.
    ($min, $max, $key) = split /-/, $range;
    if (($2 ge $min) && ($2 le $max) && ($3 eq $key)) { 
          push(@{$mylist{$2}}, $_); 
      }
    
    I ALSO TRIED THE NEXT CODE
    ($min, $max, $key) = split /-/, $range;
    if (($2 ge $min) && ($2 le $max) && /$key/) { 
          push(@{$mylist{$2}}, $_);
    }
    
    I ALSO TRIED THIS CODE BELOW TOO
    $range = <STDIN>;
    $key = <STDIN>;
    ($min, $max) = split /-/, $range;
    if (($2 ge $min) && ($2 le $max) && grep /$key/, $_) { 
          push(@{$mylist{$2}}, $_);
    }
    
    Excuse my dumbness but I can't figure it out.

    The brassmonk