perl-unicode

Re: Batch search and replace of Unicode in Perl

2000-11-24 01:56:52
There is plenty of cpan modules that will do this for you.
Checkout these modules. These plus lots of others will do 
what you want

HTML::Template (the man page has some good examples) or
Text::BasicTemplate

David


______________________________ Reply Separator _________________________________
Subject: Batch search and replace of Unicode in Perl
Author:  <james(_at_)publitek(_dot_)com> at Internet
Date:    21/11/00 14:41


Dear all,

If you can help me with the following problem I would
really appreciate it.

I am developing a touch screen visitor information kiosk
for the Natural History Museum in London.  This museum
has lots of international visitors, and they want the kiosk
in 12 languages, including Arabic, Hebrew, Hindu, etc.

We have decided that it would be best to develop this
system as UTF-8 encoded web pages.  We want to
keep the translation process separate from the HTML
encoding. We have decided that the best way to do this
would be to put markers into html templates, like
these:

<html><head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head><body>
<h1><font face="Arial Unicode MS">MARKER001</font></h1>
<p><font face="Arial Unicode MS">MARKER002</font></p>
</body></html>

(This is just for demo purposes - the real HTML is much
more complex.)

Then there will be a Unicode file containing the marker
code and the text that it needs to replace it, e.g.

"MARKER001","This is a title in e.g. Chinese"
"MARKER002","This is some body text in e.g. Chinese"
.. etc.

This file will be translated into multiple languages. (It
doesn't have to be comma delimited as above, it
could as be in a simple XML format).

What I need is a batch search and replace script that will
search for the markers and replace them with the strings
in multiple files in multiple directories.  Of course
there are lots of utilities and scripts for doing this kind of
search and replace operation, but I cannot find one
which is Unicode compliant both for the input and
the output files.

I understand that this kind of thing can be programmed
in Perl, but I am afraid my Perl programming is not up
to the task.  Does anyone have a script that can do
this kind of thing?  I would really appreciate any help
you can give me.

Many thanks

James Johnson
james(_at_)publitek(_dot_)com

<Prev in Thread] Current Thread [Next in Thread>