CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
comparing figures from 2 text files

 



user1
User

Jan 24, 2007, 11:11 AM

Post #1 of 2 (433 views)
comparing figures from 2 text files Can't Post

i have 2 text files which has ID numbers in the following format.

Ex: TextFile1 and TextFile2 files are in the following format.

14635285

23458456

56768787



I need to get the missing ID's in TextFile2. I am using the following but not working.



#!/usr/local/bin/perl

my %words;

open FILE1, 'c:\test\tibco.txt' or die $!;
while (<FILE1>) {

chomp;

$words{$_}++ ;


} close FILE1;

open FILE2, 'c:\test\MSM.txt' or die $!;

while (<FILE2>) {

chomp; # Delete the words we've found from the hash

delete @words

}

close FILE2;

print join ': ', keys %words;


KevinR
Veteran


Jan 24, 2007, 12:29 PM

Post #2 of 2 (430 views)
Re: [user1] comparing figures from 2 text files [In reply to] Can't Post

instead of:

delete @words;

you should be using:

delete $words{$_};

assumes everything else is correct though.
-------------------------------------------------

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives