Regex random values pattern match and code efficiencyby Mark.Allan (Sexton)
|on Sep 11, 2013 at 20:17 UTC||Need Help??|
Mark.Allan has asked for the
wisdom of the Perl Monks concerning the following question:
I have two types of question for the monks out there today. One is a "How do I?" and the other is a "Where can I"!
I have two files which I am parsing, this first files structure is as follows:
I need to pattern match for the values, not too difficult for the standard key=value pairs, but the "how can I" pattern match for the DEPLOY+PARAMS. again not that difficult if the value of DEPLOY_PARAMS was the same all the time but another occurence of this key in another file might look like this
Without the config and IP values and so on. I read maybe regex assertion may be able to help me?
A snippet of code so far is as follows
The second file as a structure as follows. I need to extract all values between the ' ' (6 in all)
keyAttributes('SURNAME', 'GIVENNAME', 'TITLE', 'SEX', 'ADDRESS', 'COUNTRY').
eg/ keyAttributes('DOE', 'John', 'Mr', 'Male', 'New York', 'US').
Now this again not too difficult to match with the following code
but this leads me to my 2nd type of question, "where can I" improve BOTH chunks of code to make the perl more efficient and elegant, im always looking for tips on improvement from the gurus, please bear in mind im restricted to an old 5.8 perl, maybe I can use an array for regex for example?