$i = 0;
opendir(logdir, '.') or die "Can't open directory.";
print "Enter string to search for: ";
$search = <>;
print "\n";
#print join("\n", readdir(logdir));
print "\n";
@filelist = readdir(logdir);
while($i < ($#filelist))
{
     open(logfile, @filelist[$i]);
     $i++;
     while(<logfile>)
     {
          if(m/$search/i)
          {
               print;
          }
     }
}
print "\n";
print "Press enter to continue...";
<>;
$i = 0;
while($i < ($#filelist))
{
     close(logfile, @filelist[$i]);
     $i++;
}
closedir logdir;


Ok, I think I understand you, but things still are not working right.
 
> That's easy -- you don't.
> 
> When you said:
> 
>     print;
> 
> you didn't specify what to print. So print printed $_,
> the default variable. Lots of functions either set or
> get the default variable if you don't tell them to do
> otherwise.
> 
> In the same vein:
> 
>     while (<>) {
> 
> (with or without a handle name in the <>s)
> sets $_.
> 
> And:
> 
>     if (/foo/) {
> 
> compares foo to $_.
> 
> Easy, huh?
> 
> Btw, the current line no is in $.
> 
> hth.
> 
> 

Reply via email to