Ppeoc has asked for the wisdom of the Perl Monks concerning the following question:
I need to parse the values of Name, Age and Gender of one particular person. (In reality, I have 20 such parameters to parse among other junk). These parameters are for each person are in no particular order. I am not sure how to compare @terms with @array to get values Carol, 54 and F. Any suggestions would really help me. Thank you fellow monks!Person1, Name = Lydia, Age = 20, Gender = F Person2, Name = Carol, Age = 54, Profession = Student, Gender = F, Hei +ght = 4'8 Person3, Name = Andy, Age = 37, Location = USA, Gender = M, Weight = 1 +17 Person4, Name = Nick, Age = 28, Gender = M
my @terms = qw(Name Age Gender); my $match = "Person2" while (<$file>) { chomp; if (/$match/){ @array= split(/,/); #What next??? } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Comparing an array with a regex array of strings?
by kcott (Archbishop) on Dec 17, 2015 at 06:36 UTC | |
|
Re: Comparing an array with a regex array of strings?
by NetWallah (Canon) on Dec 17, 2015 at 04:38 UTC | |
|
Re: Comparing an array with a regex array of strings?
by vinoth.ree (Monsignor) on Dec 17, 2015 at 05:43 UTC | |
by johngg (Canon) on Dec 17, 2015 at 15:24 UTC | |
by Ppeoc (Beadle) on Dec 19, 2015 at 19:24 UTC | |
|
Re: Comparing an array with a regex array of strings? -- oneliner
by Discipulus (Canon) on Dec 17, 2015 at 09:29 UTC |