Gorio3721 has asked for the wisdom of the Perl Monks concerning the following question:
What I'm trying to do is to parse the <key> = <value> fields following each "QueueManager:" line. I am trying to understand and use the '..' and/or the '...' range operators to extract only the lines between the "QueueManager:" tags. I inserted an "EndQueueManager:" line before each "QueueManager:" line in the configuration file and my script worked fine but I don't have control of the format of the config file. (It's created by IBM's WebSphere/MQ Series software). I have managed to accomplish my objevtive in a more brute force method but now I'm trying to educate myself here and learn a more elegant solution. I need to start processing a given queue manager stanza on the first "QueueManager:" line and end it on the line immediately preceeding the next "QueueManager:" line. I also want to handle an aribitrary number of <key> = <value> pairs. If I use the '..' operator I get only the "QueueManager:" lines and not the data between them. If I use the '...' operator then I get every odd stanza and skip over the even stanzas. HELP!#!/usr/bin/perl -w # use strict; while (<DATA>) { print if my $que_def = /^QueueManager:\s*$/ ... /^QueueManager:\s*$/; # print if my $que_def = /^QueueManager:\s*$/ .. /^QueueManager:\s*$/; } exit 0; __END__ ClientExitPath: ExitsDefaultPath=/var/mqm/exits LogDefaults: LogPrimaryFiles=3 LogSecondaryFiles=2 LogFilePages=1024 LogType=CIRCULAR LogBufferPages=0 LogDefaultPath=/var/mqm/log QueueManager: Name=venus.queue.manager Prefix=/MQHA/venus.queue.manager/data Directory=venus!queue!manager QueueManager: Name=craig.queue.manager Prefix=/MQHA/craig.queue.manager/data Directory=craig!queue!manager QueueManager: Name=ha.qmgr1 Prefix=/MQHA/ha.qmgr1/data Directory=ha!qmgr1 QueueManager: Name=test.manager Prefix=/MQHA/test.manager/data Directory=test!manager
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: parsing a config file
by artist (Parson) on May 21, 2003 at 17:33 UTC | |
by Gorio3721 (Acolyte) on May 23, 2003 at 18:41 UTC | |
|
Re: parsing a config file
by arturo (Vicar) on May 21, 2003 at 18:53 UTC | |
by Gorio3721 (Acolyte) on May 23, 2003 at 20:57 UTC | |
|
Re: parsing a config file
by TomDLux (Vicar) on May 21, 2003 at 19:17 UTC | |
by Gorio3721 (Acolyte) on May 23, 2003 at 21:12 UTC | |
|
Re: parsing a config file
by Not_a_Number (Prior) on May 21, 2003 at 20:15 UTC | |
by TomDLux (Vicar) on May 22, 2003 at 04:14 UTC | |
by Not_a_Number (Prior) on May 22, 2003 at 10:21 UTC | |
by TomDLux (Vicar) on May 22, 2003 at 19:23 UTC | |
|
Re: parsing a config file
by naChoZ (Curate) on May 22, 2003 at 12:54 UTC |