M
Mat W
I need help opening files. Basically, I have a directory full of html
pages. These pages are templates, with variables where i want them. For
example, lets say i have a file called test.html in my pages directory, and
it contains the following:
<head><title>$mytitle</title></head>
Now, in the script there are times when i need to print this file. What i
want to do is first set the variables, then open the file and print the html
contents.
For example:
$mytitle = "TEST";
open (FILEIN, "./pages/test.html");
@contents = <FILEIN>;
close (FILEIN);
print @contents.
The above code opens files the files and reads them fine, but the problem is
the printing.
Instead of interpolating the contents of the file, it prints EXACTLY whats
in the file.
so, given whats above, the output is literally:
<head><title>$mytitle</title></head>
instead of being
<head><title>TEST</title></head>
Is there any way to open a file so that, when the contents are printed, perl
interprets any special characters? More or less what im trying to say is,
that when the file contents are printed, its like they are in single quotes
instead of double quotes (ie. variables arent processed).
Please help me! This is the only thing stopping me from completing my
project.
P.S. my html pages contain more than a variable for the title. They contain
variables in certain places so i can have list boxes and other things that
reflect the contents of a database.
pages. These pages are templates, with variables where i want them. For
example, lets say i have a file called test.html in my pages directory, and
it contains the following:
<head><title>$mytitle</title></head>
Now, in the script there are times when i need to print this file. What i
want to do is first set the variables, then open the file and print the html
contents.
For example:
$mytitle = "TEST";
open (FILEIN, "./pages/test.html");
@contents = <FILEIN>;
close (FILEIN);
print @contents.
The above code opens files the files and reads them fine, but the problem is
the printing.
Instead of interpolating the contents of the file, it prints EXACTLY whats
in the file.
so, given whats above, the output is literally:
<head><title>$mytitle</title></head>
instead of being
<head><title>TEST</title></head>
Is there any way to open a file so that, when the contents are printed, perl
interprets any special characters? More or less what im trying to say is,
that when the file contents are printed, its like they are in single quotes
instead of double quotes (ie. variables arent processed).
Please help me! This is the only thing stopping me from completing my
project.
P.S. my html pages contain more than a variable for the title. They contain
variables in certain places so i can have list boxes and other things that
reflect the contents of a database.