My objective is to compare these 2 source file and get rid of any occurances of the function names inside Text1.c(reference file) from stub.c(working file)
The problem I have is that my code doesn't seem to be able do that. The script seems to just copy the all same function calls that I have in stub.c, without removing any occurance of the repeated function calls found in Text1.c
#!/user/bin/perl -w #note: %hash1 contains modified functions, #which has been extracted from a C source file(Test1.c). #this hash is used for referencing purposes @array = %hash1; #initiate a loop counter $loop = 0; #using for loop to get rid of new line in the array for (@array){ $array[$loop] =~ s/\n//; $loop++ } #opening file for writing open (Done, ">sim.c") or die "Can't open sim.c :$!\n"; #initiating a new hash and a string for later use %hash2; $done; #a for loop to help popping all the elements in array. for (0..6){ $fish = pop @array; $fish = pop @array; #opening of working file, which is to be compared with #the reference array(%hash1) open (Local, "stub.c") or die "Can't open stub.c :$!\n"; for $local(<Local>){ $local =~ s/\n//; #this is used to compare the 2 variable #if there is no match, assign it as a key to a hash unless ($fish eq $local){ $hash2{$local}++; } close Local; } } #print each key of the hash to verify result foreach $done ( keys %hash2){ print "$done\n"; }
Note to monk pg and monk etcshadow: I am the idiot who posted the previous thread under Anonymous Monk. A thousand apologies to monk pg and monk etcshadow. I should have posted the full code
In reply to Comparing 2 C files
by Anonymous Monk
in thread Comparing files
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |