The short answer is, yes, perl is great for this kind of tast. Now, specifically, you want to have the user input a string and then match for it in the files in the mailq? Or, perhaps the string is their email address?
 
However you want to address it, the logic will be pretty much the same:
 
### untested and without the cgi stuff
opendir(DIR,$dir) || die "can't open $dir for reading : $!\n";
my @files = readdir(DIR);
close(DIR);
 
my $string = "whatever you want to match here"; # get this from the CGI?
 
foreach my $file(@files)
{
    open(FILE,$file) || {warn "Can't open $file for reading : $!\n"; next;}
    foreach my $line(<FILE>)
    {
        if ($line =~ /$string/i)
        {
            print "$file MATCHES!!!\n"; # or whatever you wish to do with this
        }
    }
    close(FILE);
}
 
### end
 
Try it out and ask the group if you need help.
 
-----Original Message-----
From: Larry Linskey [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 09, 2004 10:09 AM
To: [EMAIL PROTECTED]
Subject: CGI grep

Hi,  I have been only working with perl for a few weeks now.

 

 I am wondering if anyone has a cgi script that I could post on a website that would allow users to grep files for a string.  I am constantly parsing smtp logs for users that did not receive an email .  I would love to offer such a tool to our support desk.

 

Thanks in advance,


Larry Linskey

 

 


This message was scanned by GatewayDefender
10:13:10 AM ET - 9/9/2004
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to