I am trying to create a webpage that will allow users to view data from a text file. The text files are named using this format: yymmdd_center.txt It correctly displays the print statement "Report for..." but it doesn't show me the text file.
Here is the code...
#!/usr/bin/perl -w
#
# Retrieve form selections & display the results
#
use strict;
use File::Find;
use CGI;
my $q = new CGI;
my $request = $ENV{"Query String"};
# Assign input to variables
my $start_month= $q->param('month');
my $start_day= $q->param('day');
my $start_year= $q->param('year');
my $start_hour= $q->param('hour');
my $start_min= $q->param('min');
my $test_site= $q->param('center');
my $string="0";
print $q->header("text/html\n\n"),
$q->start_html(-title=>"Data Report"),
"Report for $test_site from $start_hour:$start_min $start_month/$s
+tart_day/$start_year.\n";
#Find the file (yymmdd_site format)
undef$/;
find (sub
{
return if($_ =~ /^\./);
return unless($_ =~ /\.txt/i);
stat $Find::File::name;
return if -d;
return unless -r;
open(FILE, "<$Find::file::name") or return;
$string = <FILE>;
close(FILE);
return unless($string =~ /\$start_year$start_month$start_day$t
+est_site\E/i);
print $string;
}, '/(name of my directory tree)
$q->end_html;
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.