sophix has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to parse a text file contaning customer information of the following format:
AB1\tA{Daniel Wright}\sA{Jack Smith}\sB{Jane Goodwin} QW1\tA{Samantha Patton}\sC{Timothy Eeckles} AR2\tA{Jane Goodwin}
Each line may contain different number of customers and this has made it difficult for me to write a regex to capture all customers<\p>
I would like to put all the names into an array and then print them out along with the number of times a customer's name is mentioned in the file:
Jane Goodwin 2 Daniel Wright 1 Jack Smith 1 Samantha Patton 1 Timothy Eeckles 1
I used the following regex to extrac the names and put them into an array but it captures only the first customer on every line.
if ($line =~ m/{(.*?)}/g) { $customer_name = $1; push (@Customer_List, $customer_name);
How can I modify this regex to match more than one instance, i.e, multiple customer names?
Thank you
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Matching multiple {hits}
by roboticus (Chancellor) on Feb 13, 2011 at 19:13 UTC | |
by ikegami (Patriarch) on Feb 13, 2011 at 20:13 UTC | |
by sophix (Sexton) on Feb 13, 2011 at 19:22 UTC | |
by umasuresh (Hermit) on Feb 14, 2011 at 13:41 UTC | |
by sophix (Sexton) on Jun 24, 2011 at 19:05 UTC | |
Re: Matching multiple {hits}
by CountZero (Bishop) on Feb 13, 2011 at 20:36 UTC | |
Re: Matching multiple {hits}
by ikegami (Patriarch) on Feb 13, 2011 at 20:16 UTC | |
Re: Matching multiple {hits}
by Anonyrnous Monk (Hermit) on Feb 13, 2011 at 19:20 UTC |