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
In reply to parsing a config file by Gorio3721
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |