in reply to PHP to PERL ?
As for inserting data into an HTML page, Perl prefers to keep its code separate from text. So instead of dropping code snippets here and there in the page, you'd do something more like this:do 'mycode.pl';
use strict; use warnings; my ($handle, %hash); ###### Collect template contents and change to string open($handle, 'template.dat'); $_ = join '', <$handle>; close($handle); ###### Some dummy values to insert in the template $hash{'name'} = 'Theodore'; $hash{'age'} = 26; ###### Every instance of %hashkey% is replaced with ###### the corresponding value { no warnings; s/%(\w+)%/$hash{$1}/g; } print;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: PHP to PERL ?
by Anonymous Monk on Dec 27, 2005 at 23:52 UTC | |
by runrig (Abbot) on Dec 28, 2005 at 00:10 UTC | |
by Anonymous Monk on Dec 28, 2005 at 00:31 UTC |