E
Eric Strunk
Hello all,
I don't have any knoledge of perl but i have a script what is running
on the server and doesn't do his job.
It has to search along a lot of files and find a word in a line.
If it finds the word only this line has to be displayed on the screen.
Then it has to search for the next same word in the same file.
If it doesn't find the next word in a line it has to go to the next
file and do the same again.
Until the first word in the file it works nice and even the printing
is fine. But it never find the next line what contain the same search
querie, instead it goes to the next file and find there the first word
and so on.
This is the search file with printing,
-------------------------------------------------------------
#!/usr/bin/perl
use strict;
use warnings;
use CGI;
use CGI::Carp ("fatalsToBrowser");
my $q = CGI->new;
my $zoek = $q->param("zoek");
chdir "/www/xxx.xxx.xxxxxx.xx/xxxx";
my @data_files = glob "*.*";
print CGI::header();
print CGI::start_html(" my searchengine");
print <<EOT;
<P><UL><BR><FONT SIZE=+1><B><I>Legenda:</I></B></FONT><P>
1 = Recordnummer<BR>
2 = Geslacht<BR>
3 = Naam en voornamen<BR>
4 = Geboorteplaats<BR>
5 = Geboortedatum<BR>
6 = Overlijdensdatum<BR>
7 = Recordnummer vader<BR>
8 = Recordnummer moeder<BR></UL><P><HR WIDTH=33% ALIGN=LEFT>
EOT
my $hits = 0;
foreach my $file ( @data_files ) {
if ( !open F, "<$file" ) {
warn "Could not open $file ($!)\n";
next;
}
my $found = 0;
while (<F>) {
if ( /$zoek/i ) {
$hits++;
print
"<pre><b>Bestandsnaam</b><br>\n<i>$file</i></PRE><br>\n";
print "<pre> 1 2 3
4 5 6
7 8</pre>" ; \
print "<pre>$_\n<br></PRE>";
last;
}
}
close F;
}
print "<h3>", $hits ? $hits : "Geen", " bestanden gevonden</H3>";
--------------------------------------------------------------------
This is it, can anyone help me please to get all the lines in one file
and go to the next file after that.
Kind regards
Eric.
I don't have any knoledge of perl but i have a script what is running
on the server and doesn't do his job.
It has to search along a lot of files and find a word in a line.
If it finds the word only this line has to be displayed on the screen.
Then it has to search for the next same word in the same file.
If it doesn't find the next word in a line it has to go to the next
file and do the same again.
Until the first word in the file it works nice and even the printing
is fine. But it never find the next line what contain the same search
querie, instead it goes to the next file and find there the first word
and so on.
This is the search file with printing,
-------------------------------------------------------------
#!/usr/bin/perl
use strict;
use warnings;
use CGI;
use CGI::Carp ("fatalsToBrowser");
my $q = CGI->new;
my $zoek = $q->param("zoek");
chdir "/www/xxx.xxx.xxxxxx.xx/xxxx";
my @data_files = glob "*.*";
print CGI::header();
print CGI::start_html(" my searchengine");
print <<EOT;
<P><UL><BR><FONT SIZE=+1><B><I>Legenda:</I></B></FONT><P>
1 = Recordnummer<BR>
2 = Geslacht<BR>
3 = Naam en voornamen<BR>
4 = Geboorteplaats<BR>
5 = Geboortedatum<BR>
6 = Overlijdensdatum<BR>
7 = Recordnummer vader<BR>
8 = Recordnummer moeder<BR></UL><P><HR WIDTH=33% ALIGN=LEFT>
EOT
my $hits = 0;
foreach my $file ( @data_files ) {
if ( !open F, "<$file" ) {
warn "Could not open $file ($!)\n";
next;
}
my $found = 0;
while (<F>) {
if ( /$zoek/i ) {
$hits++;
"<pre><b>Bestandsnaam</b><br>\n<i>$file</i></PRE><br>\n";
print "<pre> 1 2 3
4 5 6
7 8</pre>" ; \
print "<pre>$_\n<br></PRE>";
last;
}
}
close F;
}
print "<h3>", $hits ? $hits : "Geen", " bestanden gevonden</H3>";
--------------------------------------------------------------------
This is it, can anyone help me please to get all the lines in one file
and go to the next file after that.
Kind regards
Eric.