in reply to Re: Re: Re: Parsing Code
in thread Parsing Code

HI again! Yes the sub weather is in the same file. here is the code again with your suggestion.

sub index { #&top_nav; #&weather; #$weatherData = &main; $weatherData = &weather; # $weatherData = weather(); &date; #read in template page for INDEX.HTML################################# +###### my $templateFileIndex="../htdocs/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 variables $tIndex=~s/%%INSERT DATE HERE%%/$liveDate/g; #my $weatherData= &weather; $tIndex=~s/%%WEATHER2%%/$test/g; #tIndex=~s/%%INSERT NAV HERE%%/$navPage/g; $tIndex=~s/%%WEATHER%%/$weatherData/g; #done, output page to browser #Now when this code reads the html file to do the replacements of the +variables the $weatherData prints the code from weather.cgi not the r +esult of it, that's the problem. print $tIndex; exit } ###################################################################### +###### sub weather { # read in footer template $foot="cgi-bin/weather/weather.cgi"; open(MYFOOT,"<$foot"); @footerPage=<MYFOOT>; close(MYFOOT); #condense page array into one scalar variable $weather=join("",@footerPage); $test="test"; return $weather; }

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Parsing Code
by BrowserUk (Patriarch) on Sep 17, 2002 at 20:28 UTC

    Mea culpa. I completely mis-read your problem.

    If you want to run code inside the file "cgi-bin/weather/weather.cgi", why are you opening it and reading its contents?

    The next question is what does the code inside that file look like? If it's a stand-alone program that uses (for example) LWP to obtain the weather info from another website, then to get that data into your calling script will depend on what that script does with the data? Write it to a file, print it to STDOUT etc.

    I think you will need to post the contents of that file before anyone will be able to advise you on how to get the data it generates into your program.


    Cor! Like yer ring! ... HALO dammit! ... 'Ave it yer way! Hal-lo, Mister la-de-da. ... Like yer ring!