in reply to Tagging the differencies in both files
then you would need to rewrite your File1 and File2. Some methods for that are shown in Search Replace String Not Working on text file. Either seek and truncate, or reopen the filehandle with >.my $line = __LINE__;
#!/usr/bin/perl use strict; use warnings; open (FILE1, '<', 'File1.txt') or die "Unable to open file1.txt for re +ading : $!"; open (FILE2, '<', 'File2.txt') or die "Unable to open file2.txt for re +ading : $!"; my %lines; while ( <FILE1> ) { chomp; $lines{$_}++ } while ( <FILE2> ) { chomp; $lines{$_}++ } open (FILE3, '>', 'File3.txt') or die "Unable to open file3.txt for wr +iting : $!"; for ( keys %lines ) { next if $lines{$_} > 1; print FILE3 "$_\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Tagging the differencies in both files
by CountZero (Bishop) on Jun 17, 2012 at 16:52 UTC | |
by zentara (Cardinal) on Jun 17, 2012 at 19:42 UTC | |
by h@kim (Initiate) on Jun 18, 2012 at 05:54 UTC |