Gossamer Forum
Home : General : Perl Programming :

Whats happening here???

Quote Reply
Whats happening here???
Hi. Can someone please tell me why i am getting $template1 shown instead of the variable $template1? The code is below and the HTML code it includes is available at http://www.ace-installer.com/template.html

Code is below;

#!/usr/bin/perl
print "Content-type: text/html \n\n";



#############################################
# Script Copyright 1999-2000 Ace Installer. #
# All Rights Reserved. #
##################################################
# This script is provided to help you install #
# Links 2 on your server. Provided free by #
# Ace Insataller (http://www.aceinstaller.com). #
##################################################
##################################################

###################################################

if ($ENV{'REQUEST_METHOD'} eq 'GET') {
$buffer = $ENV{'QUERY_STRING'};
}
else {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
}

@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/\=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}

# Get page 1's Template....
open (DAT, "template.html") || die ("Cannot open template.html - $!");
my @file = <DAT>;
close DAT;

my $template;
foreach (@file) { $template .= $_; }



# Open up classifieds.dat and get all the classifieds
open (ADS, "classifieds.dat");
$split_variables = <ADS>;
@classifieds = split(/<ADNEW>/,$split_variables);
close(ADS);

# The Main Sub Routines
&get_ads;


# This subroutine gets all of the ads and saves them as the variables...
sub get_ads
{

@classifieds1 = split(/:::/,$classifieds[1]);
$ID = "$classifieds1[0]";
$title = "$classifieds1[1]";
$url = "$classifieds1[2]";
$email = "$classifieds1[3]";
$advert = "$classifieds1[4]";
$name = "$classifieds1[5]";
$date = "$classifieds1[6]";

# Print's the first classified
print "$template";

$template1 = "hello";

}



Any help you can offer is much appreciated

Yours

A.J.Newby


Quote Reply
Re: Whats happening here??? In reply to
You have..

$template1 = "hello";

...but dont seem to do anything with that variable..

You have nothing like...

print "$template1";

....so what is $template1 used for?

Paul Wilson. Shocked
(Dont blame me if I'm wrong!)
Quote Reply
Re: Whats happening here??? In reply to
It is meant to be shown in the template file which i am trying to display. The only thing is that $template1 (as in the text, not whet the variable is valed at) is shown, so $template1 is not being replaced with the word 'hello'. Have a look at the template at http://www.ace-installer.com/template.html

Andy

Quote Reply
Re: Whats happening here??? In reply to
the variables in the html file won't be replced with the variables of the array because they are included in the $template scalar...

also.. you're code doesn't seem to do anything.. what does your classifieds.dat file look like?

Jerry Su
widgetz sucks