[oak perl] Comparing two files

M. Lewis cajun at cajuninc.com
Wed Jun 1 18:28:24 PDT 2005


Thanks Chris. I haven't had time to look at the code yet. I've been 
swamped with a few other things for the moment. I will however check 
this out more closely.

Nope, don't mind the deludge of responses at all. Proves TIMTOWTDI.

Thanks,
Mike


Chris Yager wrote:
> Mike, 
> 
> In my tests the most efficient way to determine 
>  unique from duplicate lines was with a Perl hash. 
> 
> Enclosed please find:
>  "dups.pl" does the work.
>  "dupslib.pm" puts content in your scalers & 
>               consumes $differences. 
> 
> dups.pl  uses a group of lines to fill the hash with $longfile, 
> it then uses another group of lines to search for unique lines 
> in $shortfile.
> The intent is to make it clear what is going on. 
> 
> dups.pl  has 2 lines commented out at the end.  
> They do the same thing as the 2 groups of earlier lines, 
> but are more obscure. 
> 
> Did you enjoy the deluge of responses?
> 
> You wrote:
> 
>>my $shortfile;
>>my $longfile;
>>my $differences;
>>
>>
>>I'm writing a script to compare two text files ($shortfile & $longfile). 
>>If a line appears in $shortfile, but that line is not in $longfile, then 
>>I want to write that line out to $differences
>>
>>I'm relatively certain it is not efficient to open $longfile for each 
>>entry in $shortfile. Both files are of the magnitude of 800+ lines.
>>
>>For example, a given line in $shortfile is found at line 333 in 
>>$longfile. Without closing and reopening $longfile, I don't know how to 
>>reset the 'pointer' in $longfile back to line 1.
>>
>>Perhaps there is a better way of doing this. I hope I've explained what 
>>I'm trying to do clearly.
>>
>>Suggestions ?
>>
>>Thanks,
>>Mike
> 
> 
> 
> Chris Yager
> (510)317-5900
> iceman at prado.com
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Oakland mailing list
> Oakland at pm.org
> http://mail.pm.org/mailman/listinfo/oakland

-- 

  Any given program will expand to fill available memory.
  20:26:01 up 7 days,  2:43,  7 users,  load average: 0.01, 0.04, 0.07

  Linux Registered User #241685  http://counter.li.org


More information about the Oakland mailing list