Here is the new code:

use strict;
use warnings;

my $file1 = $ARGV[0];
my $file2 = $ARGV[1];

open(F1, "<:utf8", $file1) || die("Can not find file $file1\n");
open(F2, "<:utf8", $file2) || die("Can not find file $file2\n");
open(O, ">:utf8", $ARGV[2]);

my $line_eng;
my $line_hin;
my $line_no = 1;

while(<F1>) {
        chomp;
        $line_eng = $_;

        $line_hin = <F2>;
        chomp($line_hin);

        binmode(O, ":utf8");
        print O "$line_no. $line_eng\n$line_hin\n\n\n";
        $line_no++;
}

close(F1);
close(F2);
close(O);

And, here I am trying to read two txt files (having equal no. of lines)
and print the contents in a single file given in the command prompt. The
files are in Unicode. I am using ActivePerl v5.8.7 in windows.

Thanks for the help.
Baskaran



-----Original Message-----
From: JupiterHost.Net [mailto:[EMAIL PROTECTED] 
Sent: 09 February 2006 21:04
To: beginners@perl.org
Subject: Re: Reading a Unicode text file



Baskaran Sankaran wrote:

> Thanks for that but still I do face problem. I did that and it raises
a 
> warning:
> 
>  
> 
> utf8 "\xFF" does not map to Unicode at second.pl line 8, 
> <$lang_sample_fh> line 1.

Excellent, so now we have soem info to start with :)


> I have 10 sentences each in different line in the input file (input
file 
> doesn't contain any blank lines between sentences). The output file
gets 
> generated, but only alternate lines are displayed properly. Lines 2,
4, 
> 6, ... are displayed as junk boxes in Unicode.

ok:

send the "new" code so we can see what line 8 is and please send a 
representation of the data in the file, the results and what you
excpect.
(IE imagine we can't pull what you expect to happen and what is 
happening from thin air, all I have is an abscure warning, something 
about every other line being goofed, and something about Unicode *'s)

Thanks ;)

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to