Hi group!
Ok, I'm trying to open all files in the directory containing my script, and
search each one for lines containing my search string. This is my code so
far:
$i = 0;
opendir(logdir, '.') or die "Can't open directory.";
print "Enter string to search for: ";
$searchstring = <>;
print "\n";
#print join("\n", readdir(logdir));
print "\n";
@filelist = readdir(logdir);
while($i < ($#filelist))
{
open(logfile, @filelist[$i]);
$i++;
while(<logfile>)
{
#if(#####line I'm currently on is m/$searchstring/i)
{
print;
}
}
}
print "Press enter to continue...";
<>;
$i = 0;
while($i < ($#filelist))
{
close(logfile, @filelist[$i]);
$i++;
}
closedir $logdir;
Now the problem is, how do I specify "The line I'm currently working on"?
Right now my program prints every line from every file in my directory, but
once I figure this out I think it should limit the output to only lines
containing my search string.
Can someone help me out?