frames in perl


How do get frames happening in perl?  I have a page that outputs info in a txt file into a table of cells, it is super long and i would like to retain the top headings for greater readabiltiy.  Can i do this somehow, if so how?

Once again, since i haven't a clue about how hard this is, if the answer looks complicated i will boost the pts.

Who is Participating?

Improve company productivity with a Business Account.Sign Up

alamoConnect With a Mentor Commented:
You can't do it with a single call to your script.

A frameset with 2 frames requires the browser to get 3 pages: the main page (frameset) and each of the frames. So what you need to do is have a way in your program to generate each of the 3 pages. (You could have the heading be a static page, not generated dynamically, but the page with the table needs to have its parameters passed to it which means the frameset needs those parameters.

There are two main ways to do this: a different script to generate each page, or a hidden field which tells the same script which page to generate.

Ok, that's how to do frames, but here's why frames aren't necessarily the best idea:

In many cases the table headings won't line up exactly with the table any more, if you separate them. This is because the browser dynamically sizes each column, using the information you give it as a guide but not as absolute dimensions. This won't look good. The solution to that is to re-print your column headings every so many rows in your table, every 25 rows for example.

The idea of one huge table has a big drawback anyway, if it's big enough: it will take a long time to load, and the browser usually won't show any of it until it's all loaded (so it knows how to size it). This means your users are looking at nothing for a while. The solution to this is to break up the table into many smaller tables, for example end the table after 25 rows and start a new one. This is only necessary with really large tables.

One more thought: I think there's a way to get a header which stays visible using pure HTML, without frames. This would only work on the latest browsers but might be the most elegant solution. I don't know the details or if it truly works - I suggest you ask this question over in the HTML section.

Hope this helps!
alamo, are you referring to style sheets?
(Note, I'm not even close to sure how those work...)
Yes, style sheets and layers. I have seen questions asked at EE over in the HTML section that make me think it could work, but I never followed the discussion enough to know myself how to do it.
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

generousAuthor Commented:
Wow, what an answer!  Umm, only it does not spell it out for me.  How is this for a strategy.   The script writes the dynmaic info to a file (not completely sure how to do this), then it calls the frameset file (using location:). The thrid file is hard coded with the heading.

Could you provide me with the code to write to that file?  Is it simply
    print tablefile "<td><b>$currenttotal</b></td>\n";   #this being done for each bit of info

Will this work?

Pls note, the issues you have raised about the table's loading time and apperence are occuring right now, but have been decided to be "liveable".
There's a possible problem there, it all depends on how your generate the information.

The problem arises in the fact that there is a single copy of bottom.html for everyone. That means if two people load the page at the same time, one may get the other's info. And more likely, if someone hits reload (or in some cases uses the Back button) they will get the latest copy of bottom.html, not the one they generated.

In some applications this is no problem, the script just generates a page with the latest info anyway, rather than a different page based on what the user asked for. If yours is like this, then what you propose will work. You need to open the file for output with
so that you can write to it. You also need to print the entire html page, not just  the <td> ... </td> bits.

If however the page you generate is different for each user and each time its loaded, a much better approach is to not use Location: for the frameset but instead for your main script to print the frameset page itself in response to the original request, and make the bottom frame a link to another script (or the same script with an additional parameter). The second script would then dynamically generate the page, just like your current script. This only works for scripts loaded from a GET form or link, not a POST, so that the URL of the bottom frame can include all the info needed to generate the page. If it works for you though, you can avoid dealing with multiple temporary files.

Let me know which approach of the above you will take, and I can provide more info if needed.
generousAuthor Commented:

I got the frames to work by writing the ouput to one of the three frame html files.  The issuse of multiple viewers of bottom.html is not a concern, just as you suggested, it is only a listing of current info.  However in the future i might make the files tmp and be erased upon clicking of a button, if privacy issues do arise.

But the location is not working.  Could it be b/c of it is below the print "content-type: text/html\n\n"; line.  I can never understand how that line effects so much of my code.  Where should the location line go?

Ps.  If you do not answer, Thanks Alamo I have learned alot from this attempt and your advice.
When you use Location it should be the only line you print  and should have \n\n at the end.

print "Location:\n\n";

You are telling the browser to go somewhere else - the place you send it will set its own Content-type and other headers.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.