Avatar of saibsk
saibsk
 asked on

parsing the file and assigning the values to hash

 12968 /opt/j2sdk1.4.0/bin/java -Dparent.script=runFlow -DOAPort=11611 -DOAIAddr=
  12966 /opt/IBM/WebSphere/AppServer/java/bin/java -Dparent.script=runServer -DOAP
  12979 /opt/j2sdk1.4.0/bin/java -Dparent.script=runOrder -DOAPort=14611 -DOAIAdd
  13002 /opt/j2sdk1.4.0/bin/java -Dparent.script=runTrader -DOAPort=15611 -DOA

I need to parse for above file content for "script=.." and add the values (ie runFlow;runServer...) to a hash.

I have another file with the similar content I have to retreive the values like above assign to another hash. Then compare the two hashes to find out the difference between two files. Please advise.
Perl

Avatar of undefined
Last Comment
ozo

8/22/2022 - Mon
Adam314

A hash is a set of key, value pairs.  From the above, what do you want to be the key, and what the value?
saibsk

ASKER
Actually I want to compare what processes i.e the values assigned to the "script" in 1 file are missing from the other file. I am not sure how would I go about that. Could you suggest me what is a good way for the comparison
ASKER CERTIFIED SOLUTION
Adam314

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ozo

open(IN,"<file2.txt") or die "File2: $!\n";
while(<IN>) {
      /script=(\S+)/ && $Found{$1}++
}
close(IN);
open(IN, "<file1.txt") or die "File1: $!\n";
while(<IN>) {
 /script=(\S+)/ && !$Found{$1} && print  ???"These are missing from file2: ":",",$1
}
close(IN);
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck