Basically open the second file first... since its got the unique values of interest. Load in the values into a hash, for easy lookup, and open the first file. if the value is already in the hash delete it!#!/usr/bin/perl -w use strict; my %unique_values; #open file two first and read in the values of interest unless(open(F2, "file2name.txt")){ die "a horrible death!"; }else{ #line by line split off the first word i.e. user01, user02, etc %unique_values = map{ (split / /,$_)[0], undef }<F2>; close F2; unless(open(F1, "file1name.txt")){ die "a horrible death!"; }else{ while(<F1>){ chomp; if(exists($unique_values{$_}){ delete $unique_values{$_}); } } close F1; } } #open a file for output unless(open(OUT, ">outputfile.txt")){ die "again we fail!"; }else{ print $_."\n" for(sort keys %unique_values); close OUT; }
In reply to Re: Seeking guidance on how to approach a task
by injunjoel
in thread Seeking guidance on how to approach a task
by mark_nelson
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |