in reply to comparing 2 files problem
How about
open(FILE1, '<file1.txt') or die("Cannot open first file: $!.\n"); open(FILE2, '<file2.txt') or die("Cannot open second file: $!.\n"); # Load up the second file into a hash, # where each line of the file is a key. %file2 = map { $_ => 1 } <FILE2>; while (<FILE1>) { if ($file2{$_}) { print("Found $_"); } else { print("Didn't find $_"); } } __END__ file1.txt ========= qwerty snakegod ebrine tarot file2.txt ========= snakegod ordo rosae moriatur tarot wrath of hibernia output ====== Didn't find qwerty Found snakegod Didn't find ebrine Found tarot
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: comparing 2 files problem
by ikegami (Patriarch) on Sep 07, 2004 at 18:52 UTC | |
by ikegami (Patriarch) on Sep 07, 2004 at 18:54 UTC |