#!/usr/bin/perl -w { # timesplit.pl Oct 08 $version = "timesplit.pl version 1.0 24 Oct 2008"; require ("cgi-lib.pl"); require "wjs_web_perl_utilities.pl"; # Set up environment. Assume .pl routine is in our directory $build_opt_env = "./build-opt-env.pl"; &check_r_access($build_opt_env); require $build_opt_env; # Define form action routine as this file. Undefined SCRIPT_NAME code # to allow possibility that this program is not being run in web environment ($form_action_routine = $ENV{"SCRIPT_NAME"}) || ($form_action_routine = &get_this_file_as_url($0)); # Check that build-opt-env set up things as expected $topdir = &check_build_opt_env_var('OPTHOME',$build_opt_env); $tempdir = &check_build_opt_env_var('USETEMPDIR',$build_opt_env); $tempdir = &abs_filespec($tempdir,"Env var USETEMPDIR"); $rundir = &check_build_opt_env_var('OPTRUNDIR',$build_opt_env); $rundir = &rel_filespec($rundir,"Env var OPTRUNDIR"); $rundir = "$topdir/$rundir"; $bindir = &abs_filespec($topdir,"Env var OPTHOME") . "/bin"; $serv = "$rundir/serv"; $listvar = "$bindir/listvar"; $listvar_command = "$listvar -a"; # Guesses for varname which user might want to split. A string # below is a valid guess if a varname in the object begins with # the string (case insensitive). The best guess is the match nearest # the beginning of the array below @JGOFS_varname_guess = ("date","event","yrmoda","hhmm","time"); $task_form_var_name = "Task_to_be_performed"; $action_form_value = "Split_time"; $refresh_cache_form_value = "Refresh_varlist_cache"; $object_form_var_name = "object_defn"; $job_id_form_var_name = "unique"; $varname_form_var_name = "var_to_split"; $format_form_var_name = "format"; &ReadParse(*form_info); $task = &get_form_var($task_form_var_name,"OPT"); if (($task eq "") || ($task eq $refresh_cache_form_value)) { &print_form; }elsif ($task eq $action_form_value) { &process_form; } else { &quit ("Bad value for form var $task_form_var_name; namely,",$task); } # Avoid "used one time" diagnostic undef %form_info; exit; } sub print_form { &printheader(); print "\n"; $title = 'Time split page'; print "
Variable to be split \n";
print qq|";
print "
Format for variable selected above \n";
print qq|
\n|;
print "
Example: format yyyymmdd_HHMM will decode datum 20081024:0026\n";
print qq|
\n";
if ($used_cached_file) {
print << "XXstuffXX-040";
if the variable lists above (which are cached) look incorrect XXstuffXX-040 } print "