vitaly has asked for the wisdom of the Perl Monks concerning the following question:

Greetings monks,
I want to create a web site using Perl/CGI.
An essential part will be getting by perl execution or reading from file a portion of a big chunk of data and showing it in the text box. By clicking "next portion" or so the next portion of data will be retrieved.
Although I already created some simple CGI web pages I am a newbie in CGI and web sites. So any hints, examples or links showing how to implement my task will be appreciated.
Thanks, Vitaly
  • Comment on Perl/CGI web page showing data by portions

Replies are listed 'Best First'.
Re: Perl/CGI web page showing data by portions
by bradcathey (Prior) on Dec 08, 2007 at 18:44 UTC

    Define "big chunk of data" and where and how is it stored?


    —Brad
    "The important work of moving the world forward does not wait to be done by perfect men." George Eliot
      Brad,
      Chunk of data will be just a file with strings. This file is huge and a part of it will be read by Perl program by some portions which, say, fit the text box. The next portion will be retrieved by pressing <next>.
      No problem with reading file portion to, say, array of strings. The question is how to show the portion in the text box and create request to read another portion.
      Thanks, Vitaly

        First of all, this is a bit dicey, and not real "webby," IMHO. Personally, I would just write it to the text box and let them scroll. Ideally, you would write the content to a <p> tag if you wanted to parse it out in chunks.

        Second, you can't just assign all the content in the file to an array. How would you keep the value of the array between round trips to the browser? You will probably need to use read to retrieve a predetermined amount of content and then store a counter of where you are in a session key and increment it as the 'Next' link is clicked. On subsequent trips back to your script for more content, you would use the session key to offset the next amount of content from your file.

        This is just one way I'm sure, but not real complicated.


        —Brad
        "The important work of moving the world forward does not wait to be done by perfect men." George Eliot
        For that you will need to be familiar with HTML forms.
        W3 Schools has online tutorials that should get you started.