Re: [NTG-context] Perl scripting (was: Arabic-utf-8)

2004-06-10 Thread Thomas A . Schmitz
Hey Hraban,
not to be a PITA, but with OS X 10.3, we moved up to perl 5.8.1. And in 
my gentoo installation, I'm now at perl 5.8.4, yessirre! ;-)

Best
Thomas
On Jun 7, 2004, at 9:45 PM, Henning Hraban Ramm wrote:
MacOS X has also only 5.6 if you don't install a newer one yourself,
and with newer than 5.8.0 you get endless trouble...
___
ntg-context mailing list
[EMAIL PROTECTED]
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] Perl scripting (was: Arabic-utf-8)

2004-06-07 Thread Henning Hraban Ramm
Am Sonntag, 06.06.04, um 23:28 Uhr (Europe/Zurich) schrieb Thomas A. 
Schmitz:

Well, if you put the
use open ':utf8';
in the header of your perl script, it should work without the hex 
editor
Not needed with Perl 5.8.x and a proper UTF8 file.
And just for the record: to put the entire file in one array, use this:
my @lines = ;
my $text = join , @lines;
   $text =~ s/PUT_YOUR/SUBSTITUIONS_HERE/esg;
Thank you, I always forget the really simple solutions. ;-)
And with File::Slurp you get it directly into a scalar.
But it looks like you got a working solution now, so have fun playing
around with it. And boy does it make one feel good when you realize 
that
you windoze people are still working with perl 5.6 -- that's the stone
age, man ;-)
MacOS X has also only 5.6 if you don't install a newer one yourself,
and with newer than 5.8.0 you get endless trouble...
Grüßlis vom Hraban!
--
http://www.fiee.net/texnique/
___
ntg-context mailing list
[EMAIL PROTECTED]
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] Perl scripting (was: Arabic-utf-8)

2004-06-06 Thread Henning Hraban Ramm
Am Sonntag, 06.06.04, um 02:19 Uhr (Europe/Zurich) schrieb Idris Samawi 
Hamid:

open(NEW,new.tex); #opens file to print out the result
better:
open NEW, , new.tex || die $!;
$_ =~ 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) = (shift, shift); # gets 2 file names from 
command line

my %conv = (# enhance as needed
\xD8xA7 = A,
\xD8xA8 = b,
\xD8xAC = j,
\xD8xAF = 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 = SOURCE) {
foreach my $key (keys %conv) {
$line =~ 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 
work).

Grüßlis vom Hraban!
--
http://www.fiee.net/texnique/
___
ntg-context mailing list
[EMAIL PROTECTED]
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] Perl scripting (was: Arabic-utf-8)

2004-06-06 Thread Idris Samawi Hamid
On Sun, 6 Jun 2004 11:09:32 +0200, Henning Hraban Ramm [EMAIL PROTECTED] 
wrote:

-
#!/usr/bin/perl -w
use strict;
use warnings;
my ($Source, $Target) = (shift, shift); # gets 2 file names from command 
line

my %conv = (# enhance as needed
\xD8xA7 = A,
\xD8xA8 = b,
\xD8xAC = j,
\xD8xAF = 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 = SOURCE) {
foreach my $key (keys %conv) {
$line =~ s/$key/$conv{$key}/g;
} # foreach
print TARGET $line;
} # while
close SOURCE;
close TARGET;
-
Thnx; I'll play around with this as well. BTW: is there any way to do this 
without the hex editor and just enter the full 4-digit character (a la 
Thomas's original suggestion) e.g.,

\x0627 = A
While the hex editor certainly works it is really slow and tedious work...
BTW: ActiveState has Perl 5.8.4, at least for Windows (I use it at work).
Ok, I found it:
http://downloads.activestate.com/ActivePerl/Windows/5.8/ActivePerl-5.8.3.809-MSWin32-x86.zip
But the web site (at first glance) sure gives one the impression that 
their latest release is
5.6.1.638

http://www.activestate.com/
http://www.activestate.com/Products/ActivePerl/
Best
Idris

--
Professor Idris Samawi Hamid
Department of Philosophy
Colorado State University
Fort Collins, CO 80523
___
ntg-context mailing list
[EMAIL PROTECTED]
http://www.ntg.nl/mailman/listinfo/ntg-context