""Jeff Peng"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> How about your two files?I should give a general way for comparing two
> files:
>
> use strict;
>
> open TXT1, "1.txt" or die "$!";
> open TXT2, "2.txt" or die "$!";
> my %diff;
>
> $diff{$_}=1 while (<TXT2>);
>
> while(<TXT1>){
>  print unless $diff{$_};
> }
>
> close TXT2;
> close TXT1;
>

for practice I tried to run your script, but i doesn't work for me it 
return an empty line but i pretty sure there's a difference between my two 
text files.
also i have question in these line of your code, i appreciate if you can 
explain what it means.

$diff{$_} = 1; #does it mean to create an array whose key are the value of 
$_ and values is always set to 1?
print unless $diff{$_} = print the line, unless ????

newbie, here please bear.

thanks.



>
> As you see,use a hash to store the second file's lines,then open the
> first file,and compare each line in first file to the hash,you could get
> the correct results.
>
> On Wed, 14 Jun 2006 13:38:23 +0530, "Preethi" <[EMAIL PROTECTED]> said:
>> Hi All,
>>
>> I'm a newbie in Perl. I was try to achive to diff two files using perl on
>> windows.
>>
>> Please suggest me how should I do this!
>>
>> Thanks,
>> Preethi
> -- 
>  Jeff Peng
>  [EMAIL PROTECTED]
>
> -- 
> http://www.fastmail.fm - Choose from over 50 domains or use your own
> 



-- 
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