mahesh.gohil has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Compare files
by Corion (Patriarch) on Apr 30, 2011 at 06:39 UTC
Re: Compare files
by wind (Priest) on Apr 30, 2011 at 06:57 UTC

    Welcome

    Check out How do I post a question effectively?. It will suggest that you enclose your code in tags:

    <code>
    ...your program...
    </code>

    This will make it readable like so:

    use strict; use warnings; my $f1 = "C:\\Documents and Settings\\KXDC7647\\Desktop\\file1.txt"; my $f2 = "C:\\Documents and Settings\\KXDC7647\\Desktop\\file2.txt"; my %results; # CONSTRUCTING HASH ARRAY BY CONTENTS OF FILE1 # IT WILL IGNORE LINE IF IT CONTAINS WHITE SPACE AT BEGINNING open FILE1, "$f1" or die "Could not open file: $! \n"; while (my $line = <FILE1>) { if ($line =~ m/^\s*$/) { next; } else { $results{$line} = 1; } } # CONSTRUCTING HASH ARRAY BY CONTENTS OF FILE2 open FILE2, "$f2" or die "Could not open file: $! \n"; while (my $line = <FILE2>) { if ($line =~ m/^\s*$/) { next; } else { $results{$line}++; } } close(FILE1); close(FILE2); # PRINTING THE DIFFERENCE IN PERL foreach my $content (keys %results) { print $content if values(%results) == 1; } foreach my $line (keys %results) { print $line if $results{$line} == 1; }
Re: Compare files
by John M. Dlugosz (Monsignor) on Apr 30, 2011 at 09:56 UTC
    What wind said. I think you would have noticed in the Preview when you were posting that your post was unreadable, no? How about adding the tags as specified, now? You can EDIT your post, you know.

    And welcome to the forum! Hang around, and you'll learn our ways. You'll find it an enriching experience.