HellO;
I need a perl script for reading a flat file (text tab) and displaying
as a formatted HTML calendar. The flat file starts "appointment name", "begin
date, time", "end date, time" and a "public" field. You could change
the file into a hash file so the script could run a for each loop on
the file and split the appointments into variables.
You could start with something like this...
#!/usr/bin/perl
require "cgi-lib.pl";
ReadParse(*input);
$datetosearch = $input{'showdate'};
$showthisdate = substr($input{'showdate'}, 0, 2);
$showthisdate1 = substr($input{'showdate'}, 2, 2);
$showthisdate2 = substr($input{'showdate'}, 4, 4);
$appointment = $input{'appointment'};
$a = $appointment
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$thismonth = $mon + 1; # month in perl is 0-11, must add 1
$thismonth1 = (Jan,Feb,Mar,Apr,May,June,July,Aug,Sept,Oct,Nov,Dec)[$mon];
$year = $year + 1900; # After year 2000, year comes in form
# 100 = 2000, etc. So this works
if ($thismonth < 10)
{ $thismonth2 = join ', 0, $thismonth; }
else
{ $thismonth2 = $thismonth }
if ($mday < 10)
{ $thisday = join ', 0, $mday; }
else
{ $thisday = $mday; }
$time0 = (join ', $thismonth2, $thisday, $year); |
Request for Question Clarification by
studboy-ga
on
09 May 2005 01:27 PDT
OK, there are some slight problems with CalendarSample.txt--
1) The tabs are not consistent throughtout--sometimes you have 2 tabs
between the fields, and sometimes you have 1--is it possible to make
that file as consistent as possible?
2) The fields themselves are not consistent--
line 1 has one date, then 2 times.
line 6 has two dates, no time.
Can the fields be defined as consistently as possible?
Either use the tabs correctly to delimited a "blank" fields,
or we need a place holder to denote the blank field.
As it turns out, the DB in the link you posed is used in several
pieces of the code. It turns out the best thing for the
parsetextfile() function to do is to convert CalendarSample.txt into
calendar.db, then proceed accordingly.
For a first pass of the code, can we simplify the multi-date appts?
ie, can we just print them out once on the start date? It turns out
it's pretty tricky to print it across several dates. We can certainly
enhance it later. Thanks.
|