in reply to Rendered Source with Perl

It generated a usable page for me (test.com Windfinder), after I replaced all occurrences of
& with &
and changed the output file extension from .txt to .htm.

Note: I tested this from a command line , not under a "real" CGI.

     Have you been high today? I see the nuns are gay! My brother yelled to me...I love you inside Ed - Benny Lava, by Buffalax

Replies are listed 'Best First'.
Re^2: Rendered Source with Perl
by Anonymous Monk on Oct 27, 2008 at 22:06 UTC
    Here, if you run this code in IE or FireFox you will see the code I am trying to save in red.
    #!/usr/bin/perl use strict; use CGI qw(:standard); use CGI::Carp; use CGI::Carp qw(fatalsToBrowser); my $q = new CGI; #generate #. my $freaky_number=int(rand(9999)) + 1; my $check_number=rand(9999); print $q->header(); print "Start Testing<br><br>"; my $k_weather = "../weather/weather_".$freaky_number.".txt"; my $render_code; print "Path: $k_weather<br><br>"; #exit; #=comment open(DDATA_IN, ">$k_weather") || warn "Can't open output file $k_we +ather: $!"; print DDATA_IN "<script type=\"text/javascript\" language=\"JavaScr +ipt\"\n"; print DDATA_IN "src=\"http://www.gmodules.com/ig/ifr?url=http://www +.windfinder.com/widget/windfinder-igoogle-gadget/windfinder_igoogle.x +ml&amp;\n"; print DDATA_IN "up_station=North%20America%20\n"; print DDATA_IN "-%20USA%20\n"; print DDATA_IN "-%20Massachusetts%20\n"; print DDATA_IN "-%20East%20of%20Boston%20Buoy%20\n"; print DDATA_IN "-%20%5Bus189%3Beast_of_boston_buoy%5D&amp;\n"; print DDATA_IN "up_wind_speed=1&amp;\n"; print DDATA_IN "up_wind_direction=1&amp;\n"; print DDATA_IN "up_wind_gusts=1&amp;\n"; print DDATA_IN "up_wave_height=1&amp;\n"; print DDATA_IN "up_wave_direction=1&amp;\n"; print DDATA_IN "up_wave_period=1&amp;\n"; print DDATA_IN "up_air_temperature=1&amp;\n"; print DDATA_IN "up_clouds=1&amp;\n"; print DDATA_IN "up_precipitation=1&amp;\n"; print DDATA_IN "up_speed=mph&amp;\n"; print DDATA_IN "up_temperature=fahrenheit&amp;\n"; print DDATA_IN "up_height=ft&amp;\n"; print DDATA_IN "up_precipitationU=inch%2F3h&amp;\n"; print DDATA_IN "synd=open&amp;\n"; print DDATA_IN "w=500&amp;\n"; print DDATA_IN "h=310&amp;\n"; print DDATA_IN "num_days=2&amp;\n"; print DDATA_IN "num_cols=2&amp;\n"; print DDATA_IN "title=test.com+-+Windfinder&amp;\n"; print DDATA_IN "lang=en&amp;\n"; print DDATA_IN "country=ALL&amp;\n"; print DDATA_IN "border=%23ffffff%7C0px%2C1px+solid+%23004488%7C0px% +2C1px+solid+%23005599%7C0px%2C1px+solid+%230077BB%7C0px%2C1px+solid+% +230088CC&amp;\n"; print DDATA_IN "output=js\">\n"; print DDATA_IN "</script>\n"; close DDATA_IN; open(DATA, "$k_weather") || warn "Can't open output file $k_weather +: $!"; undef $/; # Slurp mode $_ = <DATA>; my @render=$_; $render_code=join("",@render); close DATA; print "$render_code<br>"; my $code="<script type=\"text/javascript\" language=\"JavaScript\"> document.write('<xmp>'+((document.all) ? window.document +.body.outerHTML :document.getElementsByTagName('html')[0].innerHTML)+ +'</xmp>'); </script>"; open(DATA_OUT, ">$k_weather") || warn "Can't open output file $k_wea +ther: $!"; print DATA_OUT $render_code; close DATA_OUT; print "<br><font color=red>I need this saved::<b>Rendered Code::: $cod +e</b></font><br><br>";

    Thanks for looking!
Re^2: Rendered Source with Perl
by Anonymous Monk on Oct 27, 2008 at 21:31 UTC
    Were you able to save to a file the text rendered in red?