in reply to Get HTML source code

Hmm, care to explain a little more why you'd like to do this? I have a feeling you may be trying to cache your page for further requests, in which case there are better solutions for this problem.

Update:For example, take a look at CGI::Cache which internally pretty much does what you describe.


Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. -- Brian W. Kernighan

Replies are listed 'Best First'.
Re^2: Get HTML source code
by maestro_ba (Initiate) on Nov 04, 2005 at 17:20 UTC
    First of all thanks for the quick answers. I haven't tried any of them, but when I solve my problem I'll tell.

    I'll explain what I need:
    This HTML page the script produces is a very large page, with lots of images and forms.
    I often need to send the information this script produces by email, either by doing:
    - "Edit -> Select All", "Edit -> Copy", and "Edit -> Paste" in Outlook)
    - "File -> Send -> Page by Email"

    So, I want to strip the html code of all the forms and informations I don't need. If I can get the HTML code in a variable I can delete everything between "<form>...</form>" and therefore make a similar page, without the forms.

    If anyone can give me a better sugestion, I'll be most grateful.
    Thanks

      Oh! I completely read your original question wrong. At the expense of adding more programming logic to your script, couldn't you simply pass in a CGI parameter (as_email) and exclude certain portions of the HTML page if present? Here's is where tools such as HTML::Template and Template Toolkit are a big win:

      use strict; use warnings; use CGI; use HTML::Template; my $cgi = CGI->new; my $tmpl = HTML::Template->new( filehandle => \*DATA, associate => $cgi, ); print $cgi->header, $tmpl->output; __DATA__ <html> <head> <title>insert generic title</title> </head> <body> <h1>Hello World.</h1> <tmpl_unless as_email> <p>This only appears when as_email is not present.</p> </tmpl_unless> </body> </html>
      Try calling this CGI script with the parameter as_email set to a true value.

      jeffa

      L-LL-L--L-LL-L--L-LL-L--
      -R--R-RR-R--R-RR-R--R-RR
      B--B--B--B--B--B--B--B--
      H---H---H---H---H---H---
      (the triplet paradiddle with high-hat)