Good morning Perl Masters!
I have two interesting questions. For some time now I have been using a website script that reads from a database and places the information on the customers screen using an HTML template. (Different templates for different sites.) First the script reads a config file line by line and splits the line at an = sign. Then is processes each line with an "if statment."
The script then loads the sites template and uses the search and replace function ($template =~ s/SCRIPT_URL/$site_url/gi) to locate the keyword for the script and replace it with the site's url. Then it pulls the SQL database (of 192 Columns) and does the same thing with the data. ($template =~ s/COLUMN1/$row[0]/gi; $template =~ s/COLUMN2/$row[1]/gi; ...etc. to the end of 192 Columns) Then prints $template to the screen with it is done.
My first question is this:
Is there a way to process the config file without using a series of if statments (Making it faster)?? Right now the config file looks like this:
site_name=This Sites Name
site_url=http://www.sitesurl.com
This is getting to be a large file and it is taking a long time to process it.
My second question is similar:
Is there a better way of replacing the information in the HTML. Right now if the script finds 10 rows in the database, it has to process the 192 columns of the database into the HTML 10 times before it prints all that to the HTML template then to the customers screen. Is there a more efficient way of doing this?
Thanks for your help.
I have two interesting questions. For some time now I have been using a website script that reads from a database and places the information on the customers screen using an HTML template. (Different templates for different sites.) First the script reads a config file line by line and splits the line at an = sign. Then is processes each line with an "if statment."
The script then loads the sites template and uses the search and replace function ($template =~ s/SCRIPT_URL/$site_url/gi) to locate the keyword for the script and replace it with the site's url. Then it pulls the SQL database (of 192 Columns) and does the same thing with the data. ($template =~ s/COLUMN1/$row[0]/gi; $template =~ s/COLUMN2/$row[1]/gi; ...etc. to the end of 192 Columns) Then prints $template to the screen with it is done.
My first question is this:
Is there a way to process the config file without using a series of if statments (Making it faster)?? Right now the config file looks like this:
site_name=This Sites Name
site_url=http://www.sitesurl.com
This is getting to be a large file and it is taking a long time to process it.
My second question is similar:
Is there a better way of replacing the information in the HTML. Right now if the script finds 10 rows in the database, it has to process the 192 columns of the database into the HTML 10 times before it prints all that to the HTML template then to the customers screen. Is there a more efficient way of doing this?
Thanks for your help.