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
