#!/usr/bin/perl require 'cgi-lib.pl'; $srcpath = "/english/Chart/example6.data"; # path to data source file $MAXLINES = 10; # Lines in data source file &GetFields; # receiving the field values of the form $sid = sprintf("%d", rand(1) * 1000000); # set chart ID as random number &SaveData; # Save data record of requested chart in data source file # return dynamic page content to browser # Request parameters ("sid" - chart ID and "data" - data source) of the astrological service # clearly define, where the service should look for the chart data. print < Example 6: the chart with the data entry dialogue
Example 6 (view description)
This example shows how to use CGI interface in order to draw the chart with the data entry dialogue. The text of the data processing script can be viewed here: example6_en.pl
Date:


Time:


Latitude:


Longitude:


END exit; sub GetFields { my %params; &ReadParse(\%params) ; my ($sec,$min,$hour,$day,$mon,$year) = gmtime(time); $mon += 1; $year += 1900; $date = $params{ch_date}; $date = "$day.$mon.$year" if !$date; $time = $params{ch_time}; $time = "$hour:$min:$sec" if $time eq ""; $lat = $params{ch_lat}; $lat = "55.75" if !$lat; $lon = $params{ch_lon}; $lon = "37.58" if !$lon; } sub SaveData { my $astrosrc = $ENV{'DOCUMENT_ROOT'}.$srcpath; open(FIL, "<$astrosrc"); chomp(my @lines = ); close(FIL); push(@lines, "\n"); if(scalar(@lines) > $MAXLINES) { shift @lines; } open(FIL, ">$astrosrc"); $, = "\n" ; print FIL @lines; close(FIL); } 1;