paulwhelan
asked on
search all files in dir
id like a perl script that searches all the files in a dir
if what the users enters in the search box is in any file
or all files it will return a link to that file which can be clicked
on so the file can be viewed
thanks
if what the users enters in the search box is in any file
or all files it will return a link to that file which can be clicked
on so the file can be viewed
thanks
ASKER
i cant seem to get this to work
can u post a working version
thanks
paul
can u post a working version
thanks
paul
while( defined($File = readdir(DIR)) ){
#or
foreach $File (readdir(DIR) ){
#or
foreach $File (readdir(DIR) ){
ASKER
where does that line go in?
can someone repost the full code?
thanks
paul
can someone repost the full code?
thanks
paul
my $File;
opendir(DIR, "dirtoopen");
foreach $File (readdir(DIR)) {
open(FILE, $File) || die("Can't open file\n");
while (<FILE>) {
if (m/$UserEntry/) {
push(@Files, $File);
};
};
close(FILE);
};
close(DIR);
opendir(DIR, "dirtoopen");
foreach $File (readdir(DIR)) {
open(FILE, $File) || die("Can't open file\n");
while (<FILE>) {
if (m/$UserEntry/) {
push(@Files, $File);
};
};
close(FILE);
};
close(DIR);
ASKER
i cant seem to follow this code
can someone repost the html and perl to search all files in a dir?
thanks
paul
can someone repost the html and perl to search all files in a dir?
thanks
paul
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
could u put in some options like
case sensitivity and max number of results and anything else that might be of interest
thanks
case sensitivity and max number of results and anything else that might be of interest
thanks
Case insensitive serach:
m/$UserEntry/i
Case sensitive serach:
m/$UserEntry/
Max number of results is achived via simple counter in
foreach $File cycle with 'last;' command when counter exceeds maximum amount of files.
Sorry, but I'm not going to write the whole program for you.
m/$UserEntry/i
Case sensitive serach:
m/$UserEntry/
Max number of results is achived via simple counter in
foreach $File cycle with 'last;' command when counter exceeds maximum amount of files.
Sorry, but I'm not going to write the whole program for you.
foreach ($File = readdir(DIR)) {
open(FILE, $File) || die("Can't open file\n");
while (<FILE>) {
if (m/$UserEntry/) { push(@Files, $File);
};
close(FILE);
};
close(DIR);
#### Now generate the HTML