in reply to cgi search all txt files in a directory
You could throw in a couple of for loops...
#!/usr/bin/perl use strict; use warnings; use CGI ':standard'; print header, start_html('Player Point Tracker'), h1('Point Tracker'), start_form, body(''), p, 'Players Name: ', textfield('name'), br, submit('Search!'), end_form, p, hr; my $search_term =param('name'); for my $digit (0 .. 9) { for my $file (<$digit*>) { open (my $FILE_HANDLE, '<', $file) || die "Can't open $file: $ +! \n"; while (<$FILE_HANDLE>) { chomp; my ($word, $count) = split / /, $_; if ($word =~ /^$search_term$/) { print "At 18:00 server time $word had $count points.", +p; } } close ($FILE_HANDLE); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: cgi search all txt files in a directory
by frenchface (Initiate) on Sep 23, 2010 at 01:09 UTC | |
by perlpie (Beadle) on Sep 23, 2010 at 03:17 UTC | |
by frenchface (Initiate) on Sep 24, 2010 at 01:01 UTC | |
by frenchface (Initiate) on Sep 23, 2010 at 11:52 UTC |