Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: web-interface using data from flat files

by wfsp (Abbot)
on Nov 11, 2005 at 21:09 UTC ( [id://507866]=note: print w/replies, xml ) Need Help??

in reply to web-interface using data from flat files

How many users could be updating the data at the same time?

How big is the flatfile? If it is fairly small (e.g. less than 2k records) I think the flat file arrangement will be fine.

I have a keyword search app that uses CGI::Session. The results are stored in a hash and the hash, along with a page number, is stored in a session. 10 results/page are displayed. If the user requests next or back the script is able to send the next or previous results.

In your case you could check the data submitted by the form, update the hash, create a new session (including the page number) and display the appropriate page.

You could update/rewrite the data file at the same time (bearing in mind the questions above).

I'm a bit curious about your html. There doesn't appear to be an opening form tag. What are those anchor tags (<a></a>) doing?

How do you generate the html, how do you display the values from your hash?

More questions than answers I'm afraid :-) Good luck!

Replies are listed 'Best First'.
Re^2: web-interface using data from flat files
by sara2005 (Scribe) on Nov 12, 2005 at 02:03 UTC

    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 module here are few lines on how I generate the html using :-

    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.... ... }

      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.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://507866]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-12 15:29 GMT
Find Nodes?
    Voting Booth?

    No recent polls found