Please anyone would know how I could make the sub weather get its results processed by the index sub and than have the substitutions done in the html template? I got it to work but the result on the browser is the code literally printed on the page and not the result for weather.pl. Thank you for the BIG help! Could be a better way to bring the weather.pl program into the html template in a different way? Thank you for the BIG help!!!!

sub index { #&top_nav; &weather; #$weatherData = weather(); #$weatherData = &weather(); #$weatherData = &weather; #$weatherData = main(); &date; #read in template page for INDEX.HTML################################# +###### my $templateFileIndex="../temp_test/index.html"; open(INFILE,"<$templateFileIndex"); my @templatePageIndex=<INFILE>; close(INFILE); #condense page array into one scalar variable my $tIndex=join("",@templatePageIndex); #search-and-replace on date, nav bar and variables $tIndex=~s/%%INSERT DATE HERE%%/$liveDate/g; #my $weatherData= &weather; $tIndex=~s/%%WEATHER2%%/$test/g;#This one works jus fine I can make th +e substitution. #It doesn't work #$tIndex=~s/%%WEATHER%%/$weatherData2/g; #$tIndex=~s/%%WEATHER%%/$weatherData/g; #$tIndex=~s/%%WEATHER%%/&weather/g; #$tIndex=~s/%%WEATHER%%/$weather/g; #done, output page to browser print $tIndex; exit } ###################################################################### +###### sub weather { # read in footer template $foot="c:/progra~1/apache~1/apache/cgi-bin/weather/weather.pl"; #This +program print a weather forecast into html page template open(MYFOOT,"<$foot"); @footerPage=<MYFOOT>; close(MYFOOT); #condense page array into one scalar variable $weather=join("",@footerPage); $test="Test variable, passing value to html template"; return $weather; }

In reply to Template Parsing by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.