Is someone out there to help me please
Thanx
> -----Original Message-----
> From: Najamuddin, Junaid
> Sent: Wednesday, July 25, 2001 5:59 PM
> To: '[EMAIL PROTECTED]'
> Subject: Comparing two text files and outputting difference
>
> Hi,
>
> I am brand new on Perl
> Learning slowly though
> I will appreciate someone's help on this
> I wrote a small script with someone's help
> The script opens up two text files and goes thru it line by line
> They both are in same format. firstfile has all the entries the secondfile
> has some lines or entries missing.
> The script compares firstfile with secondfile and then spits out the whole
> line which is missing in the secondfile
> Instead of spiting the whole line I want the script to tell me the name of
> one specific string from the line, not the whole line
> I tried but was unable to do it correctly.
> Later I changed the firstfile entirely so that it has only one column of
> the names I am looking for in the secondfile but it did not work since it
> spitted all the names from the firstfile.
> I am attaching both firstfile and second file
> What I need is instead of comparing with firstfile I want it to compare it
> to thirdfile which only has names in one column
>
> In short I want the script to compare thirdfile (this has all entries in
> one column) with secondfile and spits me what it did not find in
> secondfile.
> If someone can help me please
>
> << File: firstfile.txt >> << File: secondfile.txt >> << File:
> Thirdfile.txt >>
> Thanks
> Junaid
>
> use Win32;
> use Net::SMTP;
>
> my($input1, $input2); # Defining txt files
>
> # First file
> $input1 = "./secondfile.txt"; # List of Svcs currently running
>
> #second file
> $input2 = "./firstfile.txt"; # List of All Svcs which should be running
>
> my(@arr1, @arr2, @result); # Defining arrays
>
> my($match, $cnt, $currentval1, $currentval2, $resultarraysize); # Defining
> scalar variables
> $match = "N";
>
> #Open first file and insert every line into @arr1
> open(INPUT, $input1) or die "Unable to open $input1."; # Open the txt
> file and place it filehandle
>
> $cnt = 0;
> while ( <INPUT> ) # Looping thru the file
> {
> $arr1[$cnt] = $_;
> $cnt = $cnt + 1;
> }
> close (INPUT);
>
> #Open second file and insert every line into @arr2
> open(INPUT, $input2) or die "Unable to open $input2."; # Open the txt
> file and place it filehandle
>
> $cnt = 0;
> while ( <INPUT> ) # Looping thru the file
> {
> $arr2[$cnt] = $_;
> $cnt = $cnt + 1;
> }
> close (INPUT);
>
> # Outer loop is for second file (firstfile)
> # Inner loop is for first file (secondfile)
> # Taking one element from @arr2 and comparing it with all the elements in
> @arr1 and
> # If their is no match then insert it into final result array.
>
> $cnt = 0;
> foreach $currentval2 (@arr2)
> {
> foreach $currentval1 (@arr1)
> {
> if ($currentval1 eq $currentval2)
> {
> $match = "Y";
> }
> }
> if ($match eq "N")
> {
> $result[$cnt] = $currentval2;
> $cnt = $cnt + 1;
> }
>
> $match = "N";
> }
>
> $resultarraysize = 0;
> foreach $currentval1 (@result)
> {
> $resultarraysize = $resultarraysize + 1;
> }
>
> if ($resultarraysize > 0 )
> {
> print "\nFollowing services are not Functioning\n\n"; # If some svc
> is not functioning
> foreach $currentval1 (@result)
> {
> print "$currentval1";
>
> }
> }
> else
> {
> print "\nAll Services are Functioning Fine\n"; # When all svcs are
> running fine when there is no difference between
> # both files
> }
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]