This very green newbie would like to compare two files, let's say File1 
and File2.   I
want to put the difference from File2 only, into a new file, File3.

For example:

File1.txt
oranges
apples
bananas

File2.txt
apples
kiwi
bananas

The result I want for File3 is the new entry in File2, which is kiwi.  (I
don't care that oranges was in File1 and not File2.)

I tried using a nested foreach loop structure, but I can't get that to 
work and I have a feeling using nested foreach's is not the way to go.

I'm guessing somehow I should use hashs, but I've never used a hash for 
anything and I don't really know how to use a hash.  Can someone help ?

Here's my feeble attempt:

my $file1;
my $file2;

my @file1 = qw(oranges apples bananas);
my @file2 = qw(apples kiwi bananas);

foreach $file2 (@file2){
       foreach $file2 (@file2){
        #print "$mastervob $tempvob \n";
        if ($file2 eq $file1) {
            last;                       # I would like to go up to the 
toplevel "foreach" here, but I don't know how to do it
            }                           # and I'm not sure this would even 
work.
        else{
            print "$file2 \n";
        } 
    }
}

Reply via email to