Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: web-interface using data from flat files

by sara2005 (Scribe)
on Nov 12, 2005 at 02:03 UTC ( [id://507912] : note . print w/replies, xml ) Need Help??


in reply to Re: web-interface using data from flat files
in thread web-interface using data from flat files

fortunately, the system has been set-up such that only one user will be working with one file at a time.

I am afraid the file size is more than 20kb for maxcase

I am curious to know how you pass Hashes of Hashes (HoH) from one page to another. Can you provide little more details?

The html i have shown is only a portion of the complete code.. I may have deleted few unknowingly as I meant to just give a glimpse of what i did. As I mentioned earlier, I read the data file, store the data in AoH, then for the selected page no, I churn out html rows with Varname (which is what you see in anchor tags as the intent was to show the variable name to the user), Min, Value and Max. I generate the html codes using cgi.pm module here are few lines on how I generate the html using cgi.pm :-

AoH is the array of hashes which holds the data read from the flat file

@required will hold the all the array index that corresponds to the selected page. for example, if you take the sample data file I have given, if user selects pagenum as 1 , then I have a logic to store 0 and 1 to @required. If the user selects pagenum as 2, then 2 and 3 are stored in @required. Then, I use that in a for loop to go to each of the array and print the elements I need from the hash.

... foreach $ii (@required) { ... .. $query->a( $AoH[$ii]{'VarName'}), $query->hidden( -name=>'min', -value=>$AoH[$ii]{'Min'}). $query->a($AoH[$ii]{'Min'}), ... etc.... ... }

Replies are listed 'Best First'.
Re^3: web-interface using data from flat files
by wfsp (Abbot) on Nov 15, 2005 at 06:51 UTC

    Apologies for the delay in getting back to you.

    The only state information you need to maintain is the current page. Using this you know which data to send to the browser and which to write back to disk. Here is one approach.

    It uses CGI::Session (but a hidden field could be used). It also uses HTML::Template.

    If you decided to try it be sure to create a dir called 'tmp' in the same dir as the script (used by CGI::Session). It won't work otherwise.

    Also, I changed the structure (see below) to a HoHoH. This method alows a 'page' full of data to be easily extracted/displayed/written back to disk.

    The HTML is not pretty (!) and will of course need attention. For the sake of this demo I have used a 'back' and 'next' button to move between the pages.