From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/15336 Path: main.gmane.org!not-for-mail From: Henning Hraban Ramm Newsgroups: gmane.comp.tex.context Subject: Re: Perl scripting (was: Arabic-utf-8) Date: Sun, 6 Jun 2004 11:09:32 +0200 Sender: ntg-context-admin@ntg.nl Message-ID: <3960A2BA-B799-11D8-B99E-0030659899AA@fiee.net> References: Reply-To: ntg-context@ntg.nl NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 (Apple Message framework v553) Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1086513133 20575 80.91.224.253 (6 Jun 2004 09:12:13 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 6 Jun 2004 09:12:13 +0000 (UTC) Original-X-From: ntg-context-admin@ntg.nl Sun Jun 06 11:12:03 2004 Return-path: Original-Received: from ref.vet.uu.nl ([131.211.172.13] helo=ref.ntg.nl) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BWthD-0005JA-00 for ; Sun, 06 Jun 2004 11:12:03 +0200 Original-Received: from ref.ntg.nl (localhost.localdomain [127.0.0.1]) by ref.ntg.nl (Postfix) with ESMTP id 8489510B13; Sun, 6 Jun 2004 11:11:58 +0200 (MEST) Original-Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.185]) by ref.ntg.nl (Postfix) with ESMTP id A324010B02 for ; Sun, 6 Jun 2004 11:09:34 +0200 (MEST) Original-Received: from [212.227.126.206] (helo=mrelayng.kundenserver.de) by moutng.kundenserver.de with esmtp (Exim 3.35 #1) id 1BWteo-0007ic-00 for ntg-context@ntg.nl; Sun, 06 Jun 2004 11:09:34 +0200 Original-Received: from [83.76.51.132] (helo=fiee.net) by mrelayng.kundenserver.de with asmtp (Exim 3.35 #1) id 1BWteo-0000gH-00 for ntg-context@ntg.nl; Sun, 06 Jun 2004 11:09:34 +0200 Original-To: ntg-context@ntg.nl In-Reply-To: X-Mailer: Apple Mail (2.553) X-Provags-ID: kundenserver.de abuse@kundenserver.de auth:033f42bdb3cd4a3c9b0966e414a370c7 Errors-To: ntg-context-admin@ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.0.13 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.comp.tex.context:15336 X-Report-Spam: http://spam.gmane.org/gmane.comp.tex.context:15336 Am Sonntag, 06.06.04, um 02:19 Uhr (Europe/Zurich) schrieb Idris Samawi=20= Hamid: >> open(NEW,">new.tex"); #opens file to print out the result better: open NEW, ">", "new.tex" || die $!; >> $_ =3D~ s/\xD8\xA7/A/g; #this is the actual conversion if you work with $_ you can leave it out, simply: s/\xD8\xA7/A/g; But for a series of conversions I'd suggest an hash for better overview. Whole script like this: ----- #!/usr/bin/perl -w use strict; use warnings; my ($Source, $Target) =3D (shift, shift); # gets 2 file names from=20 command line my %conv =3D ( # enhance as needed "\xD8xA7" =3D> "A", "\xD8xA8" =3D> "b", "\xD8xAC" =3D> "j", "\xD8xAF" =3D> "d" ); open SOURCE, "<", $Source || die $!; open TARGET, ">", $Target || die $!; # there are ways to read a whole file in one scalar, # e.g. with File::Slurp, but I don't know them by heart... while (my $line =3D ) { foreach my $key (keys %conv) { $line =3D~ s/$key/$conv{$key}/g; } # foreach print TARGET $line; } # while close SOURCE; close TARGET; ----- BTW: ActiveState has Perl 5.8.4, at least for Windows (I use it at=20 work). Gr=FC=DFlis vom Hraban! --=20 http://www.fiee.net/texnique/