Thierry Botten <[EMAIL PROTECTED]> wrote:
> I'm working on a way to parse a html template using perl.
You might want to look into some of the existing modules, like
HTML::Template or Text::Template.
[snip]
> 1. Create a csv-file which holds the text of all pages in a
> format like :
> Page|Variable|Lang|TEXT
CSV stands for "comma-separated values". That's actually
pipe-separated, but we know what you mean.
> e.g : home|varTxtWelcome|e|Welcome to our website\nWe
> hope you enjoy our now layout!
You might consider using ISO two-letter abbreviations (like
en and fr) for the languages, just because the standard exists
and might be easier for later maintainers to understand
immediately than abbreviations you make up. Also, you wouldn't
have to worry about what to do when you add another language
that starts with "e" or "n" or "f".
[snip]
> $line =~ s/!!activities!!/$activities{$lang}/eg;
You don't need the /e there. And you don't need the /e for a
better solution, which is to use a hash. It sounds like
you're only dealing with one language at a time, so a simple
hash should suffice. Something like
$line =~ s/!!(\w+)!!/$trans{$1}/g;
If you're dealing with multiple languages at once, you could
use a hash of hash references (sometimes called a two-
dimensional hash) like this:
$line =~ s/!!(\w+)!!/$trans{$lang}{$1}/g;
where, for example, $trans{en}{vartxtWelcome} = "Welcome to our
website\nWe hope you enjoy our new layout!".
--
Keith C. Ivey <[EMAIL PROTECTED]>
Washington, DC
_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web