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: Intermediate:
text files string value comparison

 



krishNiran
New User

Dec 20, 2009, 8:35 AM

Post #1 of 6 (1143 views)
text files string value comparison Can't Post

Detailed explanation:

hai.txt
-------
designation: Manager
name: David
age: 40


designation: Programmer
name: Bob
age: 32

designation: DBA
name: Bill
age: 50





bye.txt
--------
designation: Manager
name: Alex
age: 41


designation: Manager
name: David
age: 40


designation: Analyst
name: Mary
age: 45

designation: Programmer
name: Bob
age: 35


designation: DBA
name: Jack
age: 50


designation: Lead
name: Jim
age: 47


First perl routine should take hai.txt first entry designation and compare with bye.txt's all designation. If it does not match with any of the designation in bye.txt, it should write designation value in result.txt file like designation: Programmer does not match.
If designation matches, then it should check name.(eg: designation: DBA matches in both the file, but name Bill and Jack does not match. This should entered in another file result1.txt like designation: DBA name: Bill and Jack does not match.
Next level of comparison: If designation and name matches then it should compare age, if age differs entered in file result1.txt like designation: Programmer name: Bob age: 32 and 35 does not match.


toolic
User

Dec 20, 2009, 8:47 AM

Post #2 of 6 (1139 views)
Re: [krishNiran] text files string value comparison [In reply to] Can't Post

If you show the Perl code that you have so far, and describe what problems you are having (expected vs. actual output), people can guide you to an effective solution.


FishMonger
Veteran / Moderator

Dec 20, 2009, 8:52 AM

Post #3 of 6 (1137 views)
Re: [krishNiran] text files string value comparison [In reply to] Can't Post

Why did you post this duplicate question instead of replying to my post?

We're not going to do your homework for you, but we can give you a little assistance/guidance.

Please post your code and a specific question on the part that is giving you trouble. Include any/all warnings/errors that your code produces.


krishNiran
New User

Dec 20, 2009, 9:28 AM

Post #4 of 6 (1132 views)
Re: [krishNiran] text files string value comparison [In reply to] Can't Post

It is not duplicate post. Initially i was thinking using RegEx. I think RegEx for my problem is not easy. So i am planning to solve without RegEx using Hashmap keys comparison. I am planning to separate the String value designation: Programmer as keys and values using Hashmap1 for first text file and Hashmap2 for second text file. Then comparing the Hashmap keys(key1 and Key2) using compare/diff. Is it right approach ?


FishMonger
Veteran / Moderator

Dec 20, 2009, 9:38 AM

Post #5 of 6 (1128 views)
Re: [krishNiran] text files string value comparison [In reply to] Can't Post

Using a hash is a good approach.

Work up some code and post back when you get stuck.


7stud
Enthusiast

Dec 20, 2009, 11:06 AM

Post #6 of 6 (1124 views)
Re: [krishNiran] text files string value comparison [In reply to] Can't Post

Also, please state why you think your beginner question should be in the intermediate forum.


(This post was edited by 7stud on Dec 20, 2009, 11:06 AM)

 
 


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

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