samedi 28 mars 2015

Trying to parse string values into an array after a pattern match

I have the following lines in a text file:



<Entry>
<Key argument="ComputerNames"/>
<Value type="string" argument="localhost,localhost,engine1,engine2"/></Entry>
<Entry>
<Key argument="BranchIDMultiple"/>
<Value type="int" argument="1"/></Entry>


I know how to find the line that has ComputerNames. I know how to read the next line as well. I need to parse the line as follows where the number of arguments can be dynamic. Parse output should be: my @result = $result[0]=localhost, $result[1]=localhost, $result[2]=engine1, $result[3]=engine2. There must be one argument however there can be any number above 1.

I'm not able to construct the right regex to accomplish the split. Any ideas? That would be really helpful. Thank You!


Aucun commentaire:

Enregistrer un commentaire