ailto:[EMAIL PROTECTED]
Date: vendredi 23 janvier 2004 02:17
À: [EMAIL PROTECTED]
Cc: Perl Beginners
Objet: Re: Need help comparing lines in two files
Lets say file 1 is:
foo
bar
... continues on for 100 lines
And file 2 is:
foo
baz
bar
... continues on exactly the same 100 lines as file 1
Wou
2004 02:17
À: [EMAIL PROTECTED]
Cc: Perl Beginners
Objet: Re: Need help comparing lines in two files
Lets say file 1 is:
foo
bar
... continues on for 100 lines
And file 2 is:
foo
baz
bar
... continues on exactly the same 100 lines as file 1
Would file 2 be different from file 1 from line
ch $file1 (@file1){
if ("$file2" eq "$file1") {
next FILE2;
}
}
print "$file2 \n";
}
The output is "kiwi", which is exactly right.
kiwi
wolf blaum <[EMAIL PROTECTED]>
01/22/2004 08:38 PM
To
[EMAIL PROTECTE
> 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.
I had a very simliar problem about a week ago, which James answerd here:
http://groups.google.com/groups?q=Perl+looping+(a+lot+of)
+file
On Jan 22, 2004, at 4:52 PM, [EMAIL PROTECTED] wrote:
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
One more thing, those loops I was telling you about, just using a pair
of brackets, also keep their scope. It's a good way to clean up with
yourself, i.e.
my $foo = 40;
{
my $foo = 50;
print $foo; # prints 50
# garbage collector called on all declarations before here
}
print $foo; # prints
Lets say file 1 is:
foo
bar
... continues on for 100 lines
And file 2 is:
foo
baz
bar
... continues on exactly the same 100 lines as file 1
Would file 2 be different from file 1 from line 2 and down? Or would it
be different for line 2 and 3?
Also, the keywords:
next; Brings you to the next
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